Beispiel #1
0
        public void Broadcast(BroadcastEventType e,
                              AddItemEventArgs aea             = null,
                              RemoveItemEventArgs rea          = null,
                              SwapItemsEventArgs sea           = null,
                              SwapItemsTrhuInvEventArgs siea   = null,
                              UseItemEventArgs uea             = null,
                              DropItemEventArgs dea            = null,
                              InitializeInventoryEventArgs iea = null)
        {
            //Debug.Log($"Broadcasting event {e}");
            switch (e)
            {
            case BroadcastEventType.AddItem:
                OnAddItem?.Invoke(this, aea);
                OnChange?.Invoke(this, aea);
                break;

            case BroadcastEventType.RemoveItem:
                OnRemoveItem?.Invoke(this, rea);
                OnChange?.Invoke(this, rea);
                break;

            case BroadcastEventType.SwapItem:
                OnSwapItem?.Invoke(this, sea);
                OnChange?.Invoke(this, sea);
                break;

            case BroadcastEventType.SwapTrhuInventory:
                OnSwapTrhuInventory?.Invoke(this, siea);
                OnChange?.Invoke(this, siea);
                break;

            case BroadcastEventType.UseItem:
                OnUseItem?.Invoke(this, uea);
                OnChange?.Invoke(this, uea);
                break;

            case BroadcastEventType.DropItem:
                OnDropItem?.Invoke(this, dea);
                OnChange?.Invoke(this, dea);
                break;

            case BroadcastEventType.PickUpItem:
                OnPickUpItem?.Invoke(this, aea);
                OnChange?.Invoke(this, aea);
                break;

            case BroadcastEventType.InitializeInventory:
                OnInitializeInventory?.Invoke(this, iea);
                OnChange?.Invoke(this, iea);
                break;

            default:
                break;
            }
            if (autoSaveOnChange)
            {
                InventoryController.SaveInventoryData();
            }
        }
Beispiel #2
0
        public void Receive(UseItem useItemAction)
        {
            UseItemEventArgs useItemEventArgs = new UseItemEventArgs(this, useItemAction);

            OnUseItem?.Invoke(this, useItemEventArgs);

            // TODO

            ItemUsedEventArgs itemUsedEventArgs = new ItemUsedEventArgs(this, useItemAction);

            OnItemUsed?.Invoke(this, itemUsedEventArgs);
        }
Beispiel #3
0
 public virtual void UseItemOnStation(InteractionHandler handler, Item itemToUse)
 {
     if (OnUseItem != null)
     {
         OnUseItem.Invoke();
     }
     canAct = false;
     if (OnLeaveRange != null)
     {
         OnLeaveRange.Invoke();
     }
 }
 void Update()
 {
     if (currentEquippedItem)
     {
         Pickupable pickupable = currentEquippedItem.GetComponent <Pickupable>();
         //Using item that the player has equipped
         if (Input.GetButtonDown("Fire1"))
         {
             pickupable.OnUse(gameObject, interactSystem.GetItemInView());
             OnUseItem?.Invoke(pickupable);
         }
         if (Input.GetButtonDown("DropItem"))
         {
             DropItem(pickupable.item);
         }
     }
 }
Beispiel #5
0
 public void UnsubscribeLight(OnUseItem scr)
 {
     lightSubscribers.Remove(scr);
 }
Beispiel #6
0
 public void SubscribeLight(OnUseItem scr)
 {
     lightSubscribers.Add(scr);
 }
Beispiel #7
0
 public void UnsubscribeDay(OnUseItem scr)
 {
     daySubscribers.Remove(scr);
 }
Beispiel #8
0
 public void SubscribeDay(OnUseItem scr)
 {
     daySubscribers.Add(scr);
 }
Beispiel #9
0
        public void ReadRequest(RequestMessageIDs id, PacketReader stream, NpcInst npc)
        {
            switch (id)
            {
            case RequestMessageIDs.JumpFwd:
                OnJump?.Invoke(npc, JumpMoves.Fwd);
                break;

            case RequestMessageIDs.JumpRun:
                OnJump?.Invoke(npc, JumpMoves.Run);
                break;

            case RequestMessageIDs.JumpUp:
                OnJump?.Invoke(npc, JumpMoves.Up);
                break;

            case RequestMessageIDs.ClimbHigh:
                OnClimb?.Invoke(npc, ClimbMoves.High, new NPC.ClimbingLedge(stream));
                break;

            case RequestMessageIDs.ClimbMid:
                OnClimb?.Invoke(npc, ClimbMoves.Mid, new NPC.ClimbingLedge(stream));
                break;

            case RequestMessageIDs.ClimbLow:
                OnClimb?.Invoke(npc, ClimbMoves.Low, new NPC.ClimbingLedge(stream));
                break;

            case RequestMessageIDs.DrawFists:
                OnDrawFists?.Invoke(npc);
                break;

            case RequestMessageIDs.DrawWeapon:
                OnDrawWeapon?.Invoke(npc, npc.Inventory.GetItem(stream.ReadByte()));
                break;

            case RequestMessageIDs.AttackForward:
                OnFightMove?.Invoke(npc, FightMoves.Fwd);
                break;

            case RequestMessageIDs.AttackLeft:
                OnFightMove?.Invoke(npc, FightMoves.Left);
                break;

            case RequestMessageIDs.AttackRight:
                OnFightMove?.Invoke(npc, FightMoves.Right);
                break;

            case RequestMessageIDs.AttackRun:
                OnFightMove?.Invoke(npc, FightMoves.Run);
                break;

            case RequestMessageIDs.Parry:
                OnFightMove?.Invoke(npc, FightMoves.Parry);
                break;

            case RequestMessageIDs.Dodge:
                OnFightMove?.Invoke(npc, FightMoves.Dodge);
                break;

            case RequestMessageIDs.DropItem:
                OnDropItem?.Invoke(npc, npc.Inventory.GetItem(stream.ReadByte()), stream.ReadUShort());
                break;

            case RequestMessageIDs.TakeItem:
                if (npc.World.TryGetVob(stream.ReadUShort(), out ItemInst item))
                {
                    OnTakeItem?.Invoke(npc, item);
                }
                break;

            case RequestMessageIDs.EquipItem:
                OnEquipItem?.Invoke(npc, npc.Inventory.GetItem(stream.ReadByte()));
                break;

            case RequestMessageIDs.UnequipItem:
                OnUnequipItem?.Invoke(npc, npc.Inventory.GetItem(stream.ReadByte()));
                break;

            case RequestMessageIDs.UseItem:
                OnUseItem?.Invoke(npc, npc.Inventory.GetItem(stream.ReadByte()));
                break;

            case RequestMessageIDs.Aim:
                OnAim?.Invoke(npc);
                break;

            case RequestMessageIDs.Unaim:
                OnUnaim?.Invoke(npc);
                break;

            case RequestMessageIDs.Shoot:
                OnShoot?.Invoke(npc, stream.ReadVec3f(), stream.ReadVec3f());
                break;

            case RequestMessageIDs.Voice:
                OnVoice?.Invoke(npc, (VoiceCmd)stream.ReadByte());
                break;

            case RequestMessageIDs.HelpUp:
                if (npc.World.TryGetVob(stream.ReadUShort(), out NpcInst target))
                {
                    OnHelpUp?.Invoke(npc, target);
                }
                break;

            default:
                GUC.Log.Logger.Log("Received Script RequestMessage with invalid ID: " + id.ToString());
                break;
            }
        }