public virtual VBItem DropItem(InventoryObjectItem i) { Inventory.Remove(i); if (i.Juice == 0) { return(null); } VBItem tmp = Entities.Instance.Create(i.ItemType, Map.Instance) as VBItem; tmp.Position = Position; MultipleActionItem matmp = tmp as MultipleActionItem; if (matmp != null) { matmp.ActionMode = i.ActionMode; ConsumableItem ctmp = tmp as ConsumableItem; if (ctmp != null) { ctmp.Juice = i.Juice; } } tmp.PostCreate(); tmp.PhysicsModel.Bodies[0].ClearForces(); return(tmp); }
public void CreateActiveItem(string itmType) { //shared item creation activeHeldItem = (VBItem)Entities.Instance.Create(itmType, Parent); activeHeldItem.Owner = this; activeHeldItem.PostCreate(); }
public virtual bool TakeItem(VBItem i) { if (!CanHoldItem(i.Type)) { return(false); } bool shouldAdd = true; //is it ammo and i already have one? if (i.Type as AmmoItemType != null) { InventoryObjectItem existing = Inventory.Find(search => search.ItemType == i.Type); if (existing != null) { existing.Juice += (i as AmmoItem).Juice; shouldAdd = false; } } if (shouldAdd) { InventoryObjectItem tmp = new InventoryObjectItem(); tmp.SetType(i.Type); ConsumableItem ctmp = i as ConsumableItem; if (ctmp != null) { tmp.SetJuice(ctmp.Juice); if (ctmp.Juice > 0) { VBWeaponItem wtmp = ctmp as VBWeaponItem; if (wtmp != null) { tmp.AmmoType = wtmp.AmmoTypeLoaded; } } } Inventory.Add(tmp); } i.SetForDeletion(false); return(true); }
public virtual void UpdateCurrentItem() { if (EntitySystemWorld.Instance.WorldSimulationType == WorldSimulationTypes.Editor) { return; } //handle my current object if any if (activeHeldItem != null) { if (activeHeldItemAttachedObject != null) { Detach(activeHeldItemAttachedObject); activeHeldItemAttachedObject = null; } activeHeldItem.SetForDeletion(false); activeHeldItem = null; /* TODO: ONLINE ITEM SUPPORT - TO DO WHEN PORTING * if (EntitySystemWorld.Instance.IsServer()) * Server_SendSetactiveHeldItemToClients(EntitySystemWorld.Instance.RemoteEntityWorlds);*/ } if (GetCurItem != null) { CreateActiveItem(GetCurItem.ItemType.Name); //activeHeldItem.Server_EnableSynchronizationPositionsToClients = false; //transfer the info from the itm to the newly created gun ConsumableItem consItm = activeHeldItem as ConsumableItem; if (consItm != null) { consItm.Juice = GetCurItem.Juice; consItm.ActionMode = GetCurItem.ActionMode; VBWeaponItem wpnItm = consItm as VBWeaponItem; if (wpnItm != null) { wpnItm.AmmoTypeLoaded = GetCurItem.AmmoType; } } //TODO: PREVENT THE OBJECT ATTACHMENT BUG //CreateactiveHeldItemAttachedObject(); /* ONLINE ITEM SUPPORT - TO DO WHEN PORTING * if (EntitySystemWorld.Instance.IsServer()) * Server_SendSetactiveHeldItemToClients(EntitySystemWorld.Instance.RemoteEntityWorlds);*/ } else { if (Type.MeleeAttacks != null) { if (primaryActive) { CreateActiveItem(Type.MeleeAttacks[0]); } else { CreateActiveItem(Type.MeleeAttacks[1]); } } } }