Beispiel #1
0
 void OnTurnStarting(LivingObject living)
 {
     if (this.UseMaxMoveTime)
     {
         m_maxMoveTimer.Change(m_config.MaxMoveTime, TimeSpan.FromMilliseconds(-1));
     }
 }
Beispiel #2
0
        public override void AddLiving(LivingObject living)
        {
            m_livings.Add(living);

            if (m_livings.Count == 1)
                Start();
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        public override void AddLiving(LivingObject living)
        {
            if (m_livingCount == 0)
                m_environment.SendTo(m_player, ObjectVisibility.Public);

            m_livingCount++;
        }
Beispiel #5
0
        internal static LivingObject Create(World world, LivingObjectBuilder builder)
        {
            var ob = new LivingObject(builder);

            ob.Initialize(world);
            return(ob);
        }
Beispiel #6
0
        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();
        }
Beispiel #9
0
 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);
 }
Beispiel #10
0
        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++;
        }
Beispiel #13
0
        public override void AddLiving(LivingObject living)
        {
            if (m_livingCount == 0)
            {
                m_environment.SendTo(m_player, ObjectVisibility.Public);
            }

            m_livingCount++;
        }
Beispiel #14
0
        public void ReceiveDamage(LivingObject attacker, DamageCategory cat, int damage)
        {
            this.HitPoints -= damage;

            if (this.HitPoints <= 0)
            {
                Die();
            }
        }
Beispiel #15
0
        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.
        }
Beispiel #16
0
        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();
            }
        }
Beispiel #18
0
        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();
            }
        }
Beispiel #20
0
        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);
        }
Beispiel #21
0
        void EndTurnSequential(LivingObject living)
        {
            trace.TraceVerbose("EndTurnSeq {0}", living);

            AddChange(new TurnEndChange(living));

            if (TurnEnded != null)
            {
                TurnEnded(living);
            }

            this.CurrentLivingID = ObjectID.NullObjectID;
        }
Beispiel #22
0
        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);
        }
Beispiel #23
0
        void StartTurnSequential(LivingObject living)
        {
            trace.TraceVerbose("StartTurnSeq {0}", living);

            this.CurrentLivingID = living.ObjectID;

            living.TurnStarted();

            AddChange(new TurnStartChange(living));

            if (TurnStarting != null)
            {
                TurnStarting(living);
            }
        }
Beispiel #24
0
        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);
             */
        }
Beispiel #25
0
        void RemoveControllable(LivingObject living)
        {
            if (this.IsConnected)
            {
                SendRemoveControllable(living);

                UninitControllableVisionTracker(living);
            }

            UninitControllable(living);

            var ok = m_controllables.Remove(living);

            Debug.Assert(ok);
        }
Beispiel #26
0
        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);
             */
        }
Beispiel #27
0
        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);
            }
        }
Beispiel #28
0
        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);
        }
Beispiel #29
0
 public TurnStartChange(LivingObject living)
 {
     this.Living = living;
 }
Beispiel #30
0
 internal void AddLiving(LivingObject living)
 {
     VerifyAccess();
     m_livings.Add(living);
 }
Beispiel #31
0
 public ActionProgressChange(LivingObject ob)
     : base(ob)
 {
 }
Beispiel #32
0
        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);
            }
        }
Beispiel #33
0
 public virtual void AddLiving(LivingObject living)
 {
 }
Beispiel #34
0
 public override void RemoveLiving(LivingObject living)
 {
 }
Beispiel #35
0
 internal void RemoveLiving(LivingObject living)
 {
     VerifyAccess();
     m_livings.Remove(living);
 }
Beispiel #36
0
        void StartTurnSequential(LivingObject living)
        {
            trace.TraceVerbose("StartTurnSeq {0}", living);

            this.CurrentLivingID = living.ObjectID;

            living.TurnStarted();

            AddChange(new TurnStartChange(living));

            if (TurnStarting != null)
                TurnStarting(living);
        }
Beispiel #37
0
        void EndTurnSequential(LivingObject living)
        {
            trace.TraceVerbose("EndTurnSeq {0}", living);

            AddChange(new TurnEndChange(living));

            if (TurnEnded != null)
                TurnEnded(living);

            this.CurrentLivingID = ObjectID.NullObjectID;
        }
Beispiel #38
0
 public override void SetupLivingAsControllable(LivingObject living)
 {
     living.SetAI(new DwarfAI(living));
 }
Beispiel #39
0
 void UninitControllable(LivingObject living)
 {
     living.Destructed -= OnControllableDestructed;
     living.Controller  = null;
 }
Beispiel #40
0
 public override void AddLiving(LivingObject living)
 {
 }
Beispiel #41
0
 internal void RemoveLiving(LivingObject living)
 {
     VerifyAccess();
     m_livings.Remove(living);
 }
Beispiel #42
0
 public ActionDoneChange(LivingObject ob)
     : base(ob)
 {
 }
Beispiel #43
0
 internal void AddLiving(LivingObject living)
 {
     VerifyAccess();
     m_livings.Add(living);
 }
Beispiel #44
0
 public TurnEndChange(LivingObject living)
 {
     this.Living = living;
 }
Beispiel #45
0
 public override void AddLiving(LivingObject living)
 {
 }
Beispiel #46
0
 public ActionStartedChange(LivingObject ob)
     : base(ob)
 {
 }
Beispiel #47
0
 public ActionProgressChange(LivingObject ob)
     : base(ob)
 {
 }
Beispiel #48
0
 public virtual void RemoveLiving(LivingObject living)
 {
 }
Beispiel #49
0
 public virtual void RemoveLiving(LivingObject living)
 {
 }
Beispiel #50
0
        public void ReceiveDamage(LivingObject attacker, DamageCategory cat, int damage)
        {
            this.HitPoints -= damage;

            if (this.HitPoints <= 0)
                Die();
        }
Beispiel #51
0
 public ActionDoneChange(LivingObject ob)
     : base(ob)
 {
 }
Beispiel #52
0
 internal static LivingObject Create(World world, LivingObjectBuilder builder)
 {
     var ob = new LivingObject(builder);
     ob.Initialize(world);
     return ob;
 }
Beispiel #53
0
 public SkillChange(LivingObject ob, SkillID skillID, byte level)
     : base(ob)
 {
     this.SkillID = skillID;
     this.Level = level;
 }
Beispiel #54
0
 public override void RemoveLiving(LivingObject living)
 {
 }
Beispiel #55
0
 public TurnStartChange(LivingObject living)
 {
     this.Living = living;
 }
Beispiel #56
0
 public TurnEndChange(LivingObject living)
 {
     this.Living = living;
 }
Beispiel #57
0
 public ActionStartedChange(LivingObject ob)
     : base(ob)
 {
 }
Beispiel #58
0
 public static void AddRandomWeapon(LivingObject living)
 {
     var itemIDs = Items.GetItemInfos(ItemCategory.Weapon).ToArray();
     var itemID = itemIDs[Helpers.GetRandomInt(itemIDs.Length)].ID;
     AddEquipment(living, itemID);
 }
Beispiel #59
0
 public LivingObject Create(World world)
 {
     return(LivingObject.Create(world, this));
 }
Beispiel #60
0
 public virtual void AddLiving(LivingObject living)
 {
 }