void OnTurnStarting(LivingObject living) { if (this.UseMaxMoveTime) { m_maxMoveTimer.Change(m_config.MaxMoveTime, TimeSpan.FromMilliseconds(-1)); } }
public override void AddLiving(LivingObject living) { m_livings.Add(living); if (m_livings.Count == 1) Start(); }
public static void AddRandomArmor(LivingObject living, ArmorSlot slot) { var itemIDs = Items.GetItemInfos(ItemCategory.Armor).Where(ii => ii.ArmorInfo.Slot == slot).ToArray(); var itemID = itemIDs[Helpers.GetRandomInt(itemIDs.Length)].ID; AddEquipment(living, itemID); }
public override void AddLiving(LivingObject living) { if (m_livingCount == 0) m_environment.SendTo(m_player, ObjectVisibility.Public); m_livingCount++; }
internal static LivingObject Create(World world, LivingObjectBuilder builder) { var ob = new LivingObject(builder); ob.Initialize(world); return(ob); }
static ItemObject PerformBuildItem(LivingObject builder, BuildableItem buildableItem, IEnumerable<ObjectID> sourceObjects) { if (!VerifyBuildItem(builder, buildableItem, sourceObjects)) return null; var obs = sourceObjects.Select(oid => builder.World.FindObject<ItemObject>(oid)); MaterialID materialID; if (buildableItem.MaterialID.HasValue) materialID = buildableItem.MaterialID.Value; else materialID = obs.First().MaterialID; var skillLevel = builder.GetSkillLevel(buildableItem.SkillID); var itemBuilder = new ItemObjectBuilder(buildableItem.ItemID, materialID) { Quality = skillLevel, }; var item = itemBuilder.Create(builder.World); foreach (var ob in obs) ob.Destruct(); if (item.MoveTo(builder.Environment, builder.Location) == false) throw new Exception(); return item; }
public override void AddLiving(LivingObject living) { if (m_livingCount == 0) Start(); m_livingCount++; }
public override void RemoveLiving(LivingObject living) { m_livingCount--; Debug.Assert(m_livingCount >= 0); if (m_livingCount == 0) Stop(); }
public static void AddBattleGear(LivingObject living) { Helpers.AddRandomWeapon(living); Helpers.AddRandomArmor(living, ArmorSlot.Torso); Helpers.AddRandomArmor(living, ArmorSlot.Head); Helpers.AddRandomArmor(living, ArmorSlot.Hands); Helpers.AddRandomArmor(living, ArmorSlot.Feet); }
public override void RemoveLiving(LivingObject living) { var ok = m_livings.Remove(living); Debug.Assert(ok); if (m_livings.Count == 0) Stop(); }
public override void AddLiving(LivingObject living) { m_livings.Add(living); if (m_livings.Count == 1) { Start(); } }
public override void AddLiving(LivingObject living) { if (m_livingCount == 0) { Start(); } m_livingCount++; }
public override void AddLiving(LivingObject living) { if (m_livingCount == 0) { m_environment.SendTo(m_player, ObjectVisibility.Public); } m_livingCount++; }
public void ReceiveDamage(LivingObject attacker, DamageCategory cat, int damage) { this.HitPoints -= damage; if (this.HitPoints <= 0) { Die(); } }
void OnTurnEnded(LivingObject living) { // Cancel the timer if (this.UseMaxMoveTime) { m_maxMoveTimer.Change(TimeSpan.FromMilliseconds(-1), TimeSpan.FromMilliseconds(-1)); } // XXX There's a race. The timer could fire before the cancellation, but the timer action could be run after. }
void UninitControllableVisionTracker(LivingObject living) { living.ParentChanged -= OnControllableParentChanged; if (living.Environment != null) { var tracker = GetVisionTrackerInternal(living.Environment); tracker.RemoveLiving(living); } }
public override void RemoveLiving(LivingObject living) { m_livingCount--; Debug.Assert(m_livingCount >= 0); if (m_livingCount == 0) { Stop(); } }
void SendRemoveControllable(LivingObject living) { Debug.Assert(this.IsConnected); Send(new Messages.ControllablesDataMessage() { Operation = ControllablesDataMessage.Op.Remove, Controllables = new ObjectID[] { living.ObjectID } }); }
public override void RemoveLiving(LivingObject living) { var ok = m_livings.Remove(living); Debug.Assert(ok); if (m_livings.Count == 0) { Stop(); } }
public static void AddGem(LivingObject living) { var world = living.World; var materials = Materials.GetMaterials(MaterialCategory.Gem).ToArray(); var material = materials[Helpers.GetRandomInt(materials.Length)].ID; var itemBuilder = new ItemObjectBuilder(ItemID.Gem, material); var item = itemBuilder.Create(world); item.MoveToMustSucceed(living); }
void EndTurnSequential(LivingObject living) { trace.TraceVerbose("EndTurnSeq {0}", living); AddChange(new TurnEndChange(living)); if (TurnEnded != null) { TurnEnded(living); } this.CurrentLivingID = ObjectID.NullObjectID; }
public static void AddEquipment(LivingObject living, ItemID itemID) { var world = living.World; var materials = Materials.GetMaterials(MaterialCategory.Metal).ToArray(); var material = materials[Helpers.GetRandomInt(materials.Length)].ID; var itemBuilder = new ItemObjectBuilder(itemID, material); var item = itemBuilder.Create(world); item.MoveTo(living); living.EquipItem(item); }
void StartTurnSequential(LivingObject living) { trace.TraceVerbose("StartTurnSeq {0}", living); this.CurrentLivingID = living.ObjectID; living.TurnStarted(); AddChange(new TurnStartChange(living)); if (TurnStarting != null) { TurnStarting(living); } }
static bool VerifyBuildItem(LivingObject builder, BuildableItem buildableItem, IEnumerable<ObjectID> sourceObjects) { return true; /* if (!Contains(builder.Location)) return false; var srcArray = sourceObjects.Select(oid => this.World.FindObject<ItemObject>(oid)).ToArray(); if (srcArray.Any(o => o == null || !this.Contains(o.Location))) return false; return buildableItem.MatchItems(srcArray); */ }
void RemoveControllable(LivingObject living) { if (this.IsConnected) { SendRemoveControllable(living); UninitControllableVisionTracker(living); } UninitControllable(living); var ok = m_controllables.Remove(living); Debug.Assert(ok); }
static bool VerifyBuildItem(LivingObject builder, BuildableItem buildableItem, IEnumerable <ObjectID> sourceObjects) { return(true); /* * if (!Contains(builder.Location)) * return false; * * var srcArray = sourceObjects.Select(oid => this.World.FindObject<ItemObject>(oid)).ToArray(); * * if (srcArray.Any(o => o == null || !this.Contains(o.Location))) * return false; * * return buildableItem.MatchItems(srcArray); */ }
void OnControllableParentChanged(LivingObject living, ContainerObject _src, ContainerObject _dst) { var src = _src as EnvironmentObject; if (src != null) { var tracker = GetVisionTrackerInternal(src); tracker.RemoveLiving(living); } var dst = _dst as EnvironmentObject; if (dst != null) { var tracker = GetVisionTrackerInternal(src); tracker.AddLiving(living); } }
static ItemObject PerformBuildItem(LivingObject builder, BuildableItem buildableItem, IEnumerable <ObjectID> sourceObjects) { if (!VerifyBuildItem(builder, buildableItem, sourceObjects)) { return(null); } var obs = sourceObjects.Select(oid => builder.World.FindObject <ItemObject>(oid)); MaterialID materialID; if (buildableItem.MaterialID.HasValue) { materialID = buildableItem.MaterialID.Value; } else { materialID = obs.First().MaterialID; } var skillLevel = builder.GetSkillLevel(buildableItem.SkillID); var itemBuilder = new ItemObjectBuilder(buildableItem.ItemID, materialID) { Quality = skillLevel, }; var item = itemBuilder.Create(builder.World); foreach (var ob in obs) { ob.Destruct(); } item.MoveToMustSucceed(builder.Environment, builder.Location); return(item); }
public TurnStartChange(LivingObject living) { this.Living = living; }
internal void AddLiving(LivingObject living) { VerifyAccess(); m_livings.Add(living); }
public ActionProgressChange(LivingObject ob) : base(ob) { }
void CreateItems(LivingObject living, int numItems) { var gemMaterials = Materials.GetMaterials(MaterialCategory.Gem).ToArray(); for (int i = 0; i < numItems; ++i) { var material = gemMaterials[m_random.Next(gemMaterials.Length)].ID; var builder = new ItemObjectBuilder(ItemID.Gem, material); var item = builder.Create(living.World); item.MoveTo(living); } }
public virtual void AddLiving(LivingObject living) { }
public override void RemoveLiving(LivingObject living) { }
internal void RemoveLiving(LivingObject living) { VerifyAccess(); m_livings.Remove(living); }
void StartTurnSequential(LivingObject living) { trace.TraceVerbose("StartTurnSeq {0}", living); this.CurrentLivingID = living.ObjectID; living.TurnStarted(); AddChange(new TurnStartChange(living)); if (TurnStarting != null) TurnStarting(living); }
void EndTurnSequential(LivingObject living) { trace.TraceVerbose("EndTurnSeq {0}", living); AddChange(new TurnEndChange(living)); if (TurnEnded != null) TurnEnded(living); this.CurrentLivingID = ObjectID.NullObjectID; }
public override void SetupLivingAsControllable(LivingObject living) { living.SetAI(new DwarfAI(living)); }
void UninitControllable(LivingObject living) { living.Destructed -= OnControllableDestructed; living.Controller = null; }
public override void AddLiving(LivingObject living) { }
public ActionDoneChange(LivingObject ob) : base(ob) { }
public TurnEndChange(LivingObject living) { this.Living = living; }
public ActionStartedChange(LivingObject ob) : base(ob) { }
public virtual void RemoveLiving(LivingObject living) { }
public void ReceiveDamage(LivingObject attacker, DamageCategory cat, int damage) { this.HitPoints -= damage; if (this.HitPoints <= 0) Die(); }
internal static LivingObject Create(World world, LivingObjectBuilder builder) { var ob = new LivingObject(builder); ob.Initialize(world); return ob; }
public SkillChange(LivingObject ob, SkillID skillID, byte level) : base(ob) { this.SkillID = skillID; this.Level = level; }
public static void AddRandomWeapon(LivingObject living) { var itemIDs = Items.GetItemInfos(ItemCategory.Weapon).ToArray(); var itemID = itemIDs[Helpers.GetRandomInt(itemIDs.Length)].ID; AddEquipment(living, itemID); }
public LivingObject Create(World world) { return(LivingObject.Create(world, this)); }