internal static List <Messages.Combat> ApplyStance(EcsRegistrar rgs, long agentId, string stance) { var result = new Messages.Combat { Tick = rgs.NewId(), ActorId = agentId }; var stances = rgs.GetParts <Parts.SkillsModifier>(agentId).Where(p => Stances.Contains(p.Tag)); rgs.RemoveParts(agentId, stances); result.ActorAction = stance; if (stance == Vals.CombatAction.StanceAggressive) { rgs.AddPart(agentId, new Parts.SkillsModifier { Tag = Vals.CombatAction.StanceAggressive, SkillDeltas = new Dictionary <string, int> { [Vals.EntitySkillPhysical.Melee] = 1, [Vals.EntitySkillPhysical.Dodge] = -1 } }); } else if (stance == Vals.CombatAction.StanceDefensive) { rgs.AddPart(agentId, new Parts.SkillsModifier { Tag = Vals.CombatAction.StanceDefensive, SkillDeltas = new Dictionary <string, int> { [Vals.EntitySkillPhysical.Melee] = -1, [Vals.EntitySkillPhysical.Dodge] = 1 } }); } else if (stance == Vals.CombatAction.StanceStandGround) { //default stance, so the removal of previous ones means we're done. } else { throw new ArgumentException($"Invalid stance {stance}."); } return(new List <Messages.Combat> { result }); }
internal static long CreateBattlefield(EcsRegistrar rgs, IEnumerable <long> battlefieldEntityIds) { var battlefieldId = rgs.CreateEntity(); var battlefieldContainer = new Parts.Container { Description = "battlefield", Tag = Vals.ContainerTag.Battlefield, ItemsAreVisible = true, Preposition = "on" }; battlefieldEntityIds = battlefieldEntityIds ?? new long[] { }; foreach (long entityId in battlefieldEntityIds) { battlefieldContainer.EntityIds.Add(entityId); } rgs.AddPart(battlefieldId, battlefieldContainer); return(battlefieldId); }