More random changes to entity manager (IDK)
~ Just committing so I can revert changes later if I screw something up
This commit is contained in:
parent
894def692c
commit
932fcaceb3
1 changed files with 109 additions and 70 deletions
|
@ -67,7 +67,6 @@ export interface entity {
|
||||||
*/ //}
|
*/ //}
|
||||||
type entityTransformType = "heal" | "attack";
|
type entityTransformType = "heal" | "attack";
|
||||||
interface entityTransformTemplate {
|
interface entityTransformTemplate {
|
||||||
thingus: entityTransformType;
|
|
||||||
magnitude: number;
|
magnitude: number;
|
||||||
affectsHealth: boolean;
|
affectsHealth: boolean;
|
||||||
affectsBarrier: boolean;
|
affectsBarrier: boolean;
|
||||||
|
@ -78,7 +77,7 @@ type entityTransformDeterminer = (
|
||||||
entityReceivingId: entityId,
|
entityReceivingId: entityId,
|
||||||
entityPerformingPuppet: puppet,
|
entityPerformingPuppet: puppet,
|
||||||
entityReceivingPuppet: puppet,
|
entityReceivingPuppet: puppet,
|
||||||
) => entityTransformTemplate | false;
|
) => [entityTransformType, entityTransformTemplate] | false;
|
||||||
interface ability {
|
interface ability {
|
||||||
placeholder: entityTransformDeterminer; // TBA (Most abilities will not be a single instant of damage/heal)
|
placeholder: entityTransformDeterminer; // TBA (Most abilities will not be a single instant of damage/heal)
|
||||||
}
|
}
|
||||||
|
@ -100,27 +99,57 @@ interface ability {
|
||||||
}
|
}
|
||||||
return [onSameTeam]
|
return [onSameTeam]
|
||||||
}*/
|
}*/
|
||||||
function applyEntityToAttack(
|
|
||||||
entityModifiers: modifiers,
|
/*function applyAttackToEntityStats() {//else if (transformType === "heal") {
|
||||||
entityStatusEffects: statusEffect[],
|
// Apply receiver's status effects to incoming heal
|
||||||
magnitude: number,
|
const newEntityStatuses = applyHealToStatuses(
|
||||||
): number {
|
entityStats.statuses, // DRY alert
|
||||||
const attack = applyModifiersToAttack(magnitude, entityModifiers);
|
magnitude,
|
||||||
// + Apply status effects of performing entity to attack (e.g. weaken)
|
entityTransformTemplate.affectsHealth,
|
||||||
return attack;
|
entityTransformTemplate.affectsBarrier,
|
||||||
}
|
maxStatuses,
|
||||||
|
);
|
||||||
|
// + Add or remove status effects (don't compare against immunities)
|
||||||
|
return {
|
||||||
|
statuses: newEntityStatuses,
|
||||||
|
statusEffects: entityStats.statusEffects, // Placeholder
|
||||||
|
};
|
||||||
|
}*/
|
||||||
function applyAttackToEntityStatuses(
|
function applyAttackToEntityStatuses(
|
||||||
entityStatuses: statuses,
|
entityStatuses: statuses,
|
||||||
|
entityTransformTemplate: entityTransformTemplate,
|
||||||
entityModifiers: modifiers,
|
entityModifiers: modifiers,
|
||||||
entityStatusEffects: statusEffect[],
|
entityStatusEffects: statusEffect[],
|
||||||
attack: number,
|
|
||||||
affectsHealth: boolean,
|
|
||||||
affectsBarrier: boolean,
|
|
||||||
): statuses {
|
): statuses {
|
||||||
// Not sure if this should return a whole entity
|
|
||||||
// + Apply status effects of receiving entity to damage (e.g. armor break)
|
// + Apply status effects of receiving entity to damage (e.g. armor break)
|
||||||
const damage = applyModifiersToAttack(attack, entityModifiers);
|
const modifiedDamage = applyModifiersToDamage(entityTransformTemplate.magnitude, entityModifiers);
|
||||||
const newStatuses = applyDamageToStatuses(entityStatuses, damage, affectsHealth, affectsBarrier);
|
const newStatuses = applyDamageToStatuses(entityStatuses, modifiedDamage, entityTransformTemplate.affectsHealth, entityTransformTemplate.affectsBarrier);
|
||||||
|
return entityStatuses;
|
||||||
|
}
|
||||||
|
/*function applyHealToEntityStats() {//if (transformType === "attack") {
|
||||||
|
// Apply receiver's status effects to incoming damage
|
||||||
|
const incomingDamage = applyModifiersToDamage(magnitude, baseModifiers);
|
||||||
|
const newEntityStatuses = applyDamageToStatuses(
|
||||||
|
entityStats.statuses,
|
||||||
|
incomingDamage,
|
||||||
|
entityTransformTemplate.affectsHealth,
|
||||||
|
entityTransformTemplate.affectsBarrier,
|
||||||
|
);
|
||||||
|
// + Add or remove status effects (compare against immunities)
|
||||||
|
return {
|
||||||
|
statuses: newEntityStatuses,
|
||||||
|
statusEffects: entityStats.statusEffects, // Placeholder
|
||||||
|
};
|
||||||
|
} */
|
||||||
|
function applyHealToEntityStatuses(
|
||||||
|
entityStatuses: statuses,
|
||||||
|
entityTransformTemplate: entityTransformTemplate,
|
||||||
|
entityModifiers: modifiers,
|
||||||
|
entityMaxStatuses: statuses,
|
||||||
|
entityStatusEffects: statusEffect[],
|
||||||
|
): statuses {
|
||||||
|
// + Apply status effects of receiving entity to damage (e.g. heal up)
|
||||||
|
const newStatuses = applyHealToStatuses(entityStatuses, entityTransformTemplate.magnitude, entityTransformTemplate.affectsHealth, entityTransformTemplate.affectsBarrier, entityMaxStatuses);
|
||||||
return entityStatuses;
|
return entityStatuses;
|
||||||
}
|
}
|
||||||
// ? Are you meant to pipe determineEntityTransform into the resulting function?
|
// ? Are you meant to pipe determineEntityTransform into the resulting function?
|
||||||
|
@ -131,53 +160,33 @@ function applyAttackToEntityStatuses(
|
||||||
return false; // Placeholder
|
return false; // Placeholder
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
function transformEntityStats(
|
function applyEntityToAttack(
|
||||||
entityPerformingTransform: entity,
|
entityModifiers: modifiers,
|
||||||
|
entityStatusEffects: statusEffect[],
|
||||||
|
entityTransformTemplate: entityTransformTemplate,
|
||||||
|
): entityTransformTemplate {
|
||||||
|
const outgoingAttack = applyModifiersToAttack(entityTransformTemplate.magnitude, entityModifiers);
|
||||||
|
// + Apply user's status effects to outgoing attack
|
||||||
|
// (Old; same thing) + Apply status effects of performing entity to attack (e.g. weaken)
|
||||||
|
entityTransformTemplate.magnitude = outgoingAttack; // Mutating is cringe, but the other parts of the transform need to be defined first
|
||||||
|
return entityTransformTemplate;
|
||||||
|
}
|
||||||
|
function applyEntityToHeal(
|
||||||
|
entityModifiers: modifiers,
|
||||||
|
entityStatusEffects: statusEffect[],
|
||||||
|
entityTransformTemplate: entityTransformTemplate,
|
||||||
|
): entityTransformTemplate {
|
||||||
|
// + Apply user's status effects to outgoing heal
|
||||||
|
return entityTransformTemplate // There could be a heal modifier later
|
||||||
|
}
|
||||||
|
/*function transformEntityStats(
|
||||||
entityStats: entityStats,
|
entityStats: entityStats,
|
||||||
entityTransformTemplate: entityTransformTemplate,
|
entityTransformTemplate: entityTransformTemplate,
|
||||||
baseModifiers: modifiers,
|
baseModifiers: modifiers,
|
||||||
maxStatuses: statuses,
|
maxStatuses: statuses,
|
||||||
): entityStats {
|
): entityStats {
|
||||||
const transformType = entityTransformTemplate.thingus;
|
const magnitude = entityTransformTemplate.magnitude*/
|
||||||
if (transformType === "attack") {
|
//}
|
||||||
const outgoingAttack = applyModifiersToAttack(
|
|
||||||
entityTransformTemplate.magnitude,
|
|
||||||
entityPerformingTransform.baseModifiers,
|
|
||||||
);
|
|
||||||
// Apply user's status effects to outgoing attack
|
|
||||||
// Apply receiver's status effects to incoming damage
|
|
||||||
const incomingDamage = applyModifiersToDamage(outgoingAttack, baseModifiers);
|
|
||||||
const newEntityStatuses = applyDamageToStatuses(
|
|
||||||
entityStats.statuses,
|
|
||||||
incomingDamage,
|
|
||||||
entityTransformTemplate.affectsHealth,
|
|
||||||
entityTransformTemplate.affectsBarrier,
|
|
||||||
);
|
|
||||||
// Add or remove status effects
|
|
||||||
return {
|
|
||||||
statuses: newEntityStatuses,
|
|
||||||
statusEffects: entityStats.statusEffects, // Placeholder
|
|
||||||
};
|
|
||||||
} else if (transformType === "heal") {
|
|
||||||
const outgoingHeal = entityTransformTemplate.magnitude; // There could be a heal modifier later
|
|
||||||
// Apply user's status effects to outgoing heal
|
|
||||||
// Apply receiver's status effects to incoming heal
|
|
||||||
const newEntityStatuses = applyHealToStatuses(
|
|
||||||
entityStats.statuses, // DRY alert
|
|
||||||
outgoingHeal,
|
|
||||||
entityTransformTemplate.affectsHealth,
|
|
||||||
entityTransformTemplate.affectsBarrier,
|
|
||||||
maxStatuses,
|
|
||||||
);
|
|
||||||
// Add or remove status effects
|
|
||||||
return {
|
|
||||||
statuses: newEntityStatuses,
|
|
||||||
statusEffects: entityStats.statusEffects, // Placeholder
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
throw "Unknown entity transform type " + transformType; // Should be never
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*interface entityTransform extends entityTransformTemplate {
|
/*interface entityTransform extends entityTransformTemplate {
|
||||||
specificEntity?: string,
|
specificEntity?: string,
|
||||||
team: "players" | "enemies",
|
team: "players" | "enemies",
|
||||||
|
@ -303,22 +312,52 @@ function applyEntityTransformToEntityList(
|
||||||
entityPerformingTransform: entity,
|
entityPerformingTransform: entity,
|
||||||
aim: Vector3,
|
aim: Vector3,
|
||||||
): [entity[], placeholder[]?] {
|
): [entity[], placeholder[]?] {
|
||||||
|
const entityPerformingTransformModifiers = entityPerformingTransform.baseModifiers
|
||||||
|
const entityPerformingTransformStatusEffects = entityPerformingTransform.stats.statusEffects // Not good
|
||||||
const newEntityList = entityList.map(function (entityReceivingTransform: entity): entity {
|
const newEntityList = entityList.map(function (entityReceivingTransform: entity): entity {
|
||||||
const entityTransformTemplate = entityTransformDeterminer(
|
const entityTransform = entityTransformDeterminer(
|
||||||
entityPerformingTransform.id,
|
entityPerformingTransform.id,
|
||||||
entityReceivingTransform.id,
|
entityReceivingTransform.id,
|
||||||
entityPerformingTransform.puppet,
|
entityPerformingTransform.puppet,
|
||||||
entityReceivingTransform.puppet,
|
entityReceivingTransform.puppet,
|
||||||
);
|
);
|
||||||
const newEntityStats = entityTransformTemplate
|
if (entityTransform) {
|
||||||
? transformEntityStats(
|
const entityStatuses = entityPerformingTransform.stats.statuses
|
||||||
entityPerformingTransform,
|
const [entityTransformType, entityTransformTemplate] = entityTransform
|
||||||
entityReceivingTransform.stats,
|
if (entityTransformType === "attack") {
|
||||||
entityTransformTemplate,
|
const outgoingTransformTemplate = applyEntityToAttack(
|
||||||
entityReceivingTransform.baseModifiers,
|
entityPerformingTransformModifiers,
|
||||||
entityReceivingTransform.maxStatuses,
|
entityPerformingTransformStatusEffects,
|
||||||
)
|
entityTransformTemplate
|
||||||
: entityReceivingTransform.stats;
|
);
|
||||||
|
const newEntityStatuses = outgoingTransformTemplate
|
||||||
|
? applyAttackToEntityStatuses(
|
||||||
|
entityStatuses,
|
||||||
|
entityTransformTemplate,
|
||||||
|
entityReceivingTransform.baseModifiers,
|
||||||
|
entityReceivingTransform.stats.statusEffects, // This is also cringe
|
||||||
|
)
|
||||||
|
: entityStatuses; // Also cringe
|
||||||
|
} else {
|
||||||
|
assert(entityTransformType === "heal")
|
||||||
|
const outgoingTransformTemplate = applyEntityToHeal( // Lots of DRY violations here
|
||||||
|
entityPerformingTransformModifiers,
|
||||||
|
entityPerformingTransformStatusEffects,
|
||||||
|
entityTransformTemplate
|
||||||
|
);
|
||||||
|
const newEntityStatuses = outgoingTransformTemplate
|
||||||
|
? applyHealToEntityStatuses(
|
||||||
|
entityStatuses,
|
||||||
|
entityTransformTemplate,
|
||||||
|
entityReceivingTransform.baseModifiers,
|
||||||
|
entityReceivingTransform.maxStatuses,
|
||||||
|
entityReceivingTransform.stats.statusEffects, // So much cringe
|
||||||
|
)
|
||||||
|
: entityStatuses;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return entityReceivingTransform;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return [newEntityList];
|
return [newEntityList];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue