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:
loplkc loplkc 2022-06-21 10:59:31 -04:00
parent 894def692c
commit 932fcaceb3

View file

@ -67,7 +67,6 @@ export interface entity {
*/ //}
type entityTransformType = "heal" | "attack";
interface entityTransformTemplate {
thingus: entityTransformType;
magnitude: number;
affectsHealth: boolean;
affectsBarrier: boolean;
@ -78,7 +77,7 @@ type entityTransformDeterminer = (
entityReceivingId: entityId,
entityPerformingPuppet: puppet,
entityReceivingPuppet: puppet,
) => entityTransformTemplate | false;
) => [entityTransformType, entityTransformTemplate] | false;
interface ability {
placeholder: entityTransformDeterminer; // TBA (Most abilities will not be a single instant of damage/heal)
}
@ -100,27 +99,57 @@ interface ability {
}
return [onSameTeam]
}*/
function applyEntityToAttack(
entityModifiers: modifiers,
entityStatusEffects: statusEffect[],
magnitude: number,
): number {
const attack = applyModifiersToAttack(magnitude, entityModifiers);
// + Apply status effects of performing entity to attack (e.g. weaken)
return attack;
}
/*function applyAttackToEntityStats() {//else if (transformType === "heal") {
// Apply receiver's status effects to incoming heal
const newEntityStatuses = applyHealToStatuses(
entityStats.statuses, // DRY alert
magnitude,
entityTransformTemplate.affectsHealth,
entityTransformTemplate.affectsBarrier,
maxStatuses,
);
// + Add or remove status effects (don't compare against immunities)
return {
statuses: newEntityStatuses,
statusEffects: entityStats.statusEffects, // Placeholder
};
}*/
function applyAttackToEntityStatuses(
entityStatuses: statuses,
entityTransformTemplate: entityTransformTemplate,
entityModifiers: modifiers,
entityStatusEffects: statusEffect[],
attack: number,
affectsHealth: boolean,
affectsBarrier: boolean,
): statuses {
// Not sure if this should return a whole entity
// + Apply status effects of receiving entity to damage (e.g. armor break)
const damage = applyModifiersToAttack(attack, entityModifiers);
const newStatuses = applyDamageToStatuses(entityStatuses, damage, affectsHealth, affectsBarrier);
const modifiedDamage = applyModifiersToDamage(entityTransformTemplate.magnitude, entityModifiers);
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;
}
// ? Are you meant to pipe determineEntityTransform into the resulting function?
@ -131,53 +160,33 @@ function applyAttackToEntityStatuses(
return false; // Placeholder
}
*/
function transformEntityStats(
entityPerformingTransform: entity,
function applyEntityToAttack(
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,
entityTransformTemplate: entityTransformTemplate,
baseModifiers: modifiers,
maxStatuses: statuses,
): entityStats {
const transformType = entityTransformTemplate.thingus;
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
}
}
const magnitude = entityTransformTemplate.magnitude*/
//}
/*interface entityTransform extends entityTransformTemplate {
specificEntity?: string,
team: "players" | "enemies",
@ -303,22 +312,52 @@ function applyEntityTransformToEntityList(
entityPerformingTransform: entity,
aim: Vector3,
): [entity[], placeholder[]?] {
const entityPerformingTransformModifiers = entityPerformingTransform.baseModifiers
const entityPerformingTransformStatusEffects = entityPerformingTransform.stats.statusEffects // Not good
const newEntityList = entityList.map(function (entityReceivingTransform: entity): entity {
const entityTransformTemplate = entityTransformDeterminer(
const entityTransform = entityTransformDeterminer(
entityPerformingTransform.id,
entityReceivingTransform.id,
entityPerformingTransform.puppet,
entityReceivingTransform.puppet,
);
const newEntityStats = entityTransformTemplate
? transformEntityStats(
entityPerformingTransform,
entityReceivingTransform.stats,
entityTransformTemplate,
entityReceivingTransform.baseModifiers,
entityReceivingTransform.maxStatuses,
)
: entityReceivingTransform.stats;
if (entityTransform) {
const entityStatuses = entityPerformingTransform.stats.statuses
const [entityTransformType, entityTransformTemplate] = entityTransform
if (entityTransformType === "attack") {
const outgoingTransformTemplate = applyEntityToAttack(
entityPerformingTransformModifiers,
entityPerformingTransformStatusEffects,
entityTransformTemplate
);
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];
}
@ -386,4 +425,4 @@ class entityManager extends actorClass<entityManagerRequest> {
export function initEntityManager() {
return new entityManager();
}
*/
*/