Inheritance: ConcreteObject, IItemObject, ISaveGameDelegate
示例#1
0
        /// <summary>
        /// For Design-time only
        /// </summary>
        public LivingObject()
            : this(null, new ObjectID(ObjectType.Living, 1234))
        {
            var props = new KeyValuePair<PropertyID, object>[]
            {
                new KeyValuePair<PropertyID, object>(PropertyID.Name, "Testname"),
                new KeyValuePair<PropertyID, object>(PropertyID.Gender, LivingGender.Male),
                new KeyValuePair<PropertyID, object>(PropertyID.MaterialID, MaterialID.Flesh),
            };

            var data = new LivingData()
            {
                ObjectID = new ObjectID(ObjectType.Living, 1234),
                LivingID = Dwarrowdelf.LivingID.Dwarf,
                CreationTick = 123,
                CreationTime = DateTime.Now,
                Properties = props,
            };

            ReceiveObjectData(data);

            var item = new ItemObject();
            item.MoveTo(this, new IntVector3());

            ReceiveObjectDataEnd();
        }
示例#2
0
        public BuildItemManager(ItemObject workbench)
        {
            this.Workbench = workbench;
            m_buildOrderQueue = new ObservableCollection<BuildOrder>();

            Init();
        }
示例#3
0
 public StoreToStockpileJob(IJobObserver parent, Stockpile stockpile, ItemObject item)
     : base(parent)
 {
     this.Item = item;
     m_stockpile = stockpile;
     m_state = State.MoveToItem;
 }
示例#4
0
        /// <summary>
        /// For Design-time only
        /// </summary>
        public LivingObject()
            : this(null, new ObjectID(ObjectType.Living, 1234))
        {
            var r = new Random();

            var props = new Tuple<PropertyID, object>[]
            {
                new Tuple<PropertyID, object>(PropertyID.Name, "Testname"),
                new Tuple<PropertyID, object>(PropertyID.Gender, LivingGender.Male),
                new Tuple<PropertyID, object>(PropertyID.MaterialID, MaterialID.Flesh),
            };

            var data = new LivingData()
            {
                ObjectID = new ObjectID(ObjectType.Living, (uint)r.Next(5000)),
                LivingID = Dwarrowdelf.LivingID.Dwarf,
                CreationTick = r.Next(),
                CreationTime = DateTime.Now,
                Properties = props,
            };

            ReceiveObjectData(data);

            var item = new ItemObject();
            item.MoveTo(this, new IntPoint3());

            ReceiveObjectDataEnd();
        }
示例#5
0
        public void AddUninstallJob(ItemObject item)
        {
            var data = new InstallJobData()
            {
                Mode = InstallMode.Uninstall,
                Item = item,
            };

            item.ReservedBy = this;

            m_jobDataList.Add(data);
        }
示例#6
0
        public void AddInstallJob(ItemObject item, IntPoint3 location)
        {
            var data = new InstallJobData()
            {
                Mode = InstallMode.Install,
                Item = item,
                Location = location,
            };

            item.ReservedBy = this;

            m_jobDataList.Add(data);

            m_environment.OnTileExtraChanged(location);
        }
示例#7
0
        void OnArmorIsWornChanged(ItemObject wearable, bool isWorn)
        {
            Debug.Assert(wearable.Container == this);

            var slot = wearable.ArmorInfo.Slot;

            if (isWorn)
            {
                Debug.Assert(m_armorSlots.All(t => t.Item1 != slot));

                m_armorSlots.Add(new Tuple <ArmorSlot, ItemObject>(slot, wearable));
            }
            else
            {
                int idx = -1;

                for (int i = 0; i < m_armorSlots.Count; ++i)
                {
                    if (m_armorSlots[i].Item1 == slot)
                    {
                        idx = i;
                        break;
                    }
                }

                if (idx == -1)
                {
                    throw new Exception();
                }

                Debug.Assert(m_armorSlots[idx].Item2 == wearable);
                m_armorSlots.RemoveAt(idx);
            }

            RecalcArmorClass();
        }
示例#8
0
        bool Match(ItemObject item)
        {
            var c = this.Criteria;

            if (c == null)
                return false;

            return c.Match(item);
        }
示例#9
0
 void ItemObject_ParameterChanged(ItemObject ob)
 {
     m_itemTracker.Update(ob);
 }
示例#10
0
        public bool LocationOk(IntVector3 p, ItemObject ob)
        {
            if (!this.Area.Contains(p))
                throw new Exception();

            return GetStack(p) == GetMinStack();
        }
示例#11
0
 void ItemObject_ParameterChanged(ItemObject ob)
 {
     m_itemTracker.Update(ob);
 }
示例#12
0
        void OnWeaponIsWieldedChanged(ItemObject weapon, bool isWielded)
        {
            Debug.Assert(weapon.Parent == this);

            if (isWielded)
            {
                this.Weapon = weapon;
                Notify("Weapon");
            }
            else
            {
                this.Weapon = null;
                Notify("Weapon");
            }
        }
示例#13
0
        void OnArmorIsWornChanged(ItemObject wearable, bool isWorn)
        {
            Debug.Assert(wearable.Parent == this);

            var slot = wearable.ArmorInfo.Slot;

            if (isWorn)
            {
                Debug.Assert(m_armorSlots.All(t => t.Item1 != slot));

                m_armorSlots.Add(new Tuple<ArmorSlot, ItemObject>(slot, wearable));
            }
            else
            {
                int idx = -1;

                for (int i = 0; i < m_armorSlots.Count; ++i)
                {
                    if (m_armorSlots[i].Item1 == slot)
                    {
                        idx = i;
                        break;
                    }
                }

                if (idx == -1)
                    throw new Exception();

                Debug.Assert(m_armorSlots[idx].Item2 == wearable);
                m_armorSlots.RemoveAt(idx);
            }

            RecalcArmorClass();
        }
示例#14
0
 internal void OnItemIsEquippedChanged(ItemObject item, bool isEquipped)
 {
     if (item.IsArmor)
         OnArmorIsWornChanged(item, isEquipped);
     else if (item.IsWeapon)
         OnWeaponIsWieldedChanged(item, isEquipped);
     else
         throw new Exception();
 }
示例#15
0
        void OnIsInstalledChanged(ItemObject ob)
        {
            if (ob != this.Workbench)
                return;

            Cleanup();
        }
示例#16
0
        public static BuildItemManager FindOrCreateBuildItemManager(ItemObject workbench)
        {
            var mgr = s_buildItemManagers.FirstOrDefault(m => m.Workbench == workbench);

            if (mgr == null)
            {
                mgr = new BuildItemManager(workbench);
                s_buildItemManagers.Add(mgr);
            }

            return mgr;
        }
示例#17
0
 public static BuildItemManager FindBuildItemManager(ItemObject workbench)
 {
     return s_buildItemManagers.FirstOrDefault(m => m.Workbench == workbench);
 }
示例#18
0
		public static BuildItemManager FindBuildItemManager(ItemObject workbench)
		{
			return s_buildItemManagers.FirstOrDefault(m => m.Workbench == workbench);
		}