Exemple #1
0
    public override bool OnBlockActivated(int _indexInBlockActivationCommands, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityAlive _player)
    {
        EntityPlayerLocal entityPlayerLocal = _player as EntityPlayerLocal;
        LocalPlayerUI     uiForPlayer       = LocalPlayerUI.GetUIForPlayer(entityPlayerLocal);
        var tileEntity = _world.GetTileEntity(_cIdx, _blockPos) as TileEntitySecureLootContainer;

        if (_indexInBlockActivationCommands == 4)
        {
            if (!tileEntity.IsEmpty())
            {
                GameManager.ShowTooltipWithAlert(entityPlayerLocal, Localization.Get("ttEmptyLootContainerBeforePickup", string.Empty), "ui_denied");
                return(false);
            }
            TakeItemWithTimer(_cIdx, _blockPos, _blockValue, _player);
            return(true);
        }

        if (_indexInBlockActivationCommands == 5)
        {
            if (uiForPlayer != null)
            {
                ((XUiWindowGroup)uiForPlayer.windowManager.GetWindow("storage_box")).Controller.GetChildByType <XUiC_StorageBoxLabelWindow>().SetTileEntity(tileEntity);
                uiForPlayer.windowManager.Open("storage_box", true, false, true);
            }
            return(true);
        }

        return(base.OnBlockActivated(_indexInBlockActivationCommands, _world, _cIdx, _blockPos, _blockValue, _player));
    }
    public void OnGUI()
    {
        if (GameManager.IsDedicatedServer)
        {
            return;
        }

        LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(entityVehicle.player);

        //if (!Event.current.type.Equals(EventType.Repaint) || GameManager.Instance.IsPaused() || GameManager.Instance.m_GUIConsole.isInputActive || entityVehicle.uiforPlayer.windowManager.IsModalWindowOpen())
        if (!Event.current.type.Equals(EventType.Repaint) || GameManager.Instance.IsPaused() || GameManager.Instance.m_GUIConsole.isInputActive || uiforPlayer.windowManager.IsModalWindowOpen())
        {
            return;
        }

        if (entityVehicle == null || entityVehicle.player == null)
        {
            InitController();
            return;
        }

        if (entityVehicle.player.movementInput.bAltCameraMove || entityVehicle.player.IsDead() || !entityVehicle.hasDriver || !(entityVehicle.HasGun() || entityVehicle.HasExplosiveLauncher()))
        {
            return;
        }

        DrawCrosshair();
    }
Exemple #3
0
    public void SpawnFromGroup(string strEntityGroup, EntityPlayer player)
    {
        int EntityID = 0;

        // If the group is set, then use it.
        if (string.IsNullOrEmpty(strEntityGroup))
        {
            return;
        }

        EntityID = EntityGroups.GetRandomFromGroup(strEntityGroup);
        if (EntityID == -1)
        {
            return; // failed
        }
        Entity NewEntity = EntityFactory.CreateEntity(EntityID, player.position, player.rotation);

        if (NewEntity)
        {
            NewEntity.SetSpawnerSource(EnumSpawnerSource.StaticSpawner);
            GameManager.Instance.World.SpawnEntityInWorld(NewEntity);
            if (NewEntity is EntityAliveSDX)
            {
                LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal);
                uiforPlayer.windowManager.Open("JoinInformation", true, false, true);
                //(NewEntity as EntityAliveSDX).SetOwner(player as EntityPlayerLocal);
            }
        }
        else
        {
            Debug.Log(" Could not Spawn NPC for: " + player.EntityName + " : " + player.entityId);
        }
    }
Exemple #4
0
    // Handles what happens to the contents of the box when you pick up the block.
    private void EventData_Event(object obj)
    {
        #region EventData_Event
        World             world             = GameManager.Instance.World;
        object[]          array             = (object[])obj;
        int               clrIdx            = (int)array[0];
        BlockValue        blockValue        = (BlockValue)array[1];
        Vector3i          vector3i          = (Vector3i)array[2];
        BlockValue        block             = world.GetBlock(vector3i);
        EntityPlayerLocal entityPlayerLocal = array[3] as EntityPlayerLocal;

        TileEntityLootContainer tileEntityLootContainer = world.GetTileEntity(clrIdx, vector3i) as TileEntityLootContainer;
        if (tileEntityLootContainer != null)
        {
            world.GetGameManager().DropContentOfLootContainerServer(blockValue, vector3i, tileEntityLootContainer.entityId);
        }

        // Pick up the item and put it inyor your inventory.
        LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(entityPlayerLocal);
        ItemStack     itemStack   = new ItemStack(block.ToItemValue(), 1);
        if (!uiforPlayer.xui.PlayerInventory.AddItem(itemStack, true))
        {
            uiforPlayer.xui.PlayerInventory.DropItem(itemStack);
        }
        world.SetBlockRPC(clrIdx, vector3i, BlockValue.Air);

        #endregion
    }
    public override void Execute(MinEventParams _params)
    {
        EntityPlayerLocal entityPlayer = _params.Self as EntityPlayerLocal;

        // Loot group
        if (_params.Self as EntityPlayerLocal != null && this.lootgroup > 0)
        {
            ItemStack[] array = LootContainer.lootList[lootgroup].Spawn(GameManager.Instance.lootManager.Random, this.CreateItemCount, EffectManager.GetValue(PassiveEffects.LootGamestage, null, (float)entityPlayer.HighestPartyGameStage, entityPlayer, null, default(FastTags), true, true, true, true, 1, true), 0f, entityPlayer, new FastTags());
            for (int i = 0; i < array.Length; i++)
            {
                if (!LocalPlayerUI.GetUIForPlayer(entityPlayer).xui.PlayerInventory.AddItem(array[i], true))
                {
                    entityPlayer.world.gameManager.ItemDropServer(array[i], entityPlayer.GetPosition(), Vector3.zero, -1, 60f, false);
                }
            }
            return;
        }

        // item value.
        if (_params.Self as EntityPlayerLocal != null && this.CreateItem != null && this.CreateItemCount > 0)
        {
            ItemStack itemStack = new ItemStack(ItemClass.GetItem(this.CreateItem, false), this.CreateItemCount);
            if (!LocalPlayerUI.GetUIForPlayer(entityPlayer).xui.PlayerInventory.AddItem(itemStack, true))
            {
                entityPlayer.world.gameManager.ItemDropServer(itemStack, entityPlayer.GetPosition(), Vector3.zero, -1, 60f, false);
            }
        }
    }
    // Take logic to replace it with the Downgrade block, matching rotations.
    private void TakeTarget(object obj)
    {
        World world = GameManager.Instance.World;

        object[]          array             = (object[])obj;
        int               clrIdx            = (int)array[0];
        BlockValue        _blockValue       = (BlockValue)array[1];
        Vector3i          vector3i          = (Vector3i)array[2];
        BlockValue        block             = world.GetBlock(vector3i);
        EntityPlayerLocal entityPlayerLocal = array[3] as EntityPlayerLocal;

        // Find the block value for the pick up value, and add it to the inventory
        BlockValue    pickUpBlock = Block.GetBlockValue(this.PickedUpItemValue);
        LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(entityPlayerLocal);
        ItemStack     itemStack   = new ItemStack(pickUpBlock.ToItemValue(), 1);

        if (!uiforPlayer.xui.PlayerInventory.AddItem(itemStack, true))
        {
            uiforPlayer.xui.PlayerInventory.DropItem(itemStack);
        }

        entityPlayerLocal.PlayOneShot("Sounds/DestroyBlock/wooddestroy1");

        // Damage the block for its full health
        this.DamageBlock(world, clrIdx, vector3i, block, block.Block.blockMaterial.MaxDamage, entityPlayerLocal.entityId, false);
    }
    public override bool CheckRequirement(EntityPlayer player)
    {
        LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal);

        // The respondent is an EntityNPC, and we don't have that. Check for the patch scripted otherEntitySDX.
        Entity respondent = uiforPlayer.xui.Dialog.Respondent;

        if (respondent == null)
        {
            respondent = uiforPlayer.xui.Dialog.otherEntitySDX;
        }

        if (respondent != null)
        {
            EntityAliveSDX myEntity = player.world.GetEntity(respondent.entityId) as EntityAliveSDX;
            if (myEntity != null)
            {
                bool isTame = false;
                if (base.Value.EqualsCaseInsensitive("not"))
                {
                    isTame = !myEntity.isTame(player);
                }
                else
                {
                    isTame = myEntity.isTame(player);
                }
                return(isTame);
            }
        }
        return(false);
    }
    public override bool CheckRequirement(EntityPlayer player)
    {
        int count = 0;

        if (string.IsNullOrEmpty(Value))
        {
            Value = "1";
        }

        float flValue = 1f;

        float.TryParse(Value, out flValue);

        LocalPlayerUI        uiforPlayer     = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal);
        XUiM_PlayerInventory playerInventory = uiforPlayer.xui.PlayerInventory;
        ItemValue            item            = ItemClass.GetItem(ID);

        if (item != null)
        {
            count  = playerInventory.Backpack.GetItemCount(item, -1, -1, false);
            count += playerInventory.Toolbelt.GetItemCount(item, false, -1, -1);
            if (flValue <= count)
            {
                return(true);
            }
        }

        return(false);
    }
    public override void PerformAction(EntityPlayer player)
    {
        Debug.Log("Perform Action for OpenDialogSDX");
        LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal);

        uiforPlayer.windowManager.Open("HireInformation", true, false, true);
    }
    public override bool CheckRequirement(EntityPlayer player)
    {
        int count = 0;

        if (string.IsNullOrEmpty(Value))
        {
            Value = "1";
        }

        float flValue = 1f;

        float.TryParse(Value, out flValue);

        LocalPlayerUI        uiforPlayer     = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal);
        XUiM_PlayerInventory playerInventory = uiforPlayer.xui.PlayerInventory;
        ItemValue            item            = ItemClass.GetItem(ID);

        if (item != null)
        {
            count  = playerInventory.Backpack.GetItemCount(item, -1, -1, false);
            count += playerInventory.Toolbelt.GetItemCount(item, false, -1, -1);
            AdvLogging.DisplayLog(AdvFeatureClass, "HasItemSDX: " + item.ItemClass.GetItemName() + " Player has Count: " + count + " Needs: " + flValue);
            if (flValue <= count)
            {
                return(true);
            }
        }

        AdvLogging.DisplayLog(AdvFeatureClass, "HasItemSDX: Player does not have enough " + item.ItemClass.GetItemName() + " Count: " + count + " Needs: " + flValue);

        return(false);
    }
Exemple #11
0
    public override bool OnBlockActivated(int _indexInBlockActivationCommands, WorldBase _world, int _cIdx,
                                          Vector3i _blockPos, BlockValue _blockValue, EntityAlive _player)
    {
        if (_blockValue.ischild)
        {
            Vector3i   parentPos = Block.list[_blockValue.type].multiBlockPos.GetParentPos(_blockPos, _blockValue);
            BlockValue block     = _world.GetBlock(parentPos);
            return(this.OnBlockActivated(_indexInBlockActivationCommands, _world, _cIdx, parentPos, block, _player));
        }
        TileEntitySign tileEntitySign = _world.GetTileEntity(_cIdx, _blockPos) as TileEntitySign;

        if (tileEntitySign == null)
        {
            return(false);
        }
        switch (_indexInBlockActivationCommands)
        {
        case 0:
            if (GameManager.Instance.IsEditMode() || !tileEntitySign.IsLocked() || tileEntitySign.IsUserAllowed(GamePrefs.GetString(EnumGamePrefs.PlayerId)))
            {
                return(this.OnBlockActivated(_world, _cIdx, _blockPos, _blockValue, _player));
            }
            Manager.BroadcastPlayByLocalPlayer(_blockPos.ToVector3() + Vector3.one * 0.5f, "Misc/locked");
            return(false);

        case 1:
            tileEntitySign.SetLocked(true);
            Manager.BroadcastPlayByLocalPlayer(_blockPos.ToVector3() + Vector3.one * 0.5f, "Misc/locking");
            GameManager.ShowTooltip(_player as EntityPlayerLocal, "containerLocked");
            return(true);

        case 2:
            tileEntitySign.SetLocked(false);
            Manager.BroadcastPlayByLocalPlayer(_blockPos.ToVector3() + Vector3.one * 0.5f, "Misc/unlocking");
            GameManager.ShowTooltip(_player as EntityPlayerLocal, "containerUnlocked");
            return(true);

        case 3:
            XUiC_KeypadWindow.Open(LocalPlayerUI.GetUIForPlayer(_player as EntityPlayerLocal), tileEntitySign);
            return(true);

        case 4:
            LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(_player as EntityPlayerLocal);
            ItemStack     itemStack   = new ItemStack(_blockValue.ToItemValue(), 1);
            if (!uiforPlayer.xui.PlayerInventory.AddItem(itemStack))
            {
                uiforPlayer.xui.PlayerInventory.DropItem(itemStack);
            }
            _world.SetBlockRPC(_cIdx, _blockPos, BlockValue.Air);

            return(true);

        default:
            return(false);
        }
    }
Exemple #12
0
    void Update()
    {
        if (GameManager.IsDedicatedServer)
        {
            return;
        }

        if (entityVehicle == null || entityVehicle.player == null)
        {
            InitController();
            return;
        }

        LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(entityVehicle.player);

        //if (GameManager.Instance.IsPaused() || GameManager.Instance.m_GUIConsole.isInputActive || entityVehicle.uiforPlayer.windowManager.IsModalWindowOpen())
        if (GameManager.Instance.IsPaused() || GameManager.Instance.m_GUIConsole.isInputActive || uiforPlayer.windowManager.IsModalWindowOpen())
        {
            if (GameManager.Instance.IsPaused())
            {
                DebugMsg("GAME WAS PAUSED!");
                gameWasPaused  = true;
                gamePausedTime = Time.time;
            }
            return;
        }

        if (!entityVehicle.hasDriver)
        {
            return;
        }

        if (gameWasPaused && Time.time - 0.2f > gamePausedTime)
        {
            OnDriverOn();
            gameWasPaused = false;
        }

        //if (!(entityVehicle.HasGun() || entityVehicle.HasExplosiveLauncher()))
        //return;

        if (entityVehicle.HasGun() && Input.GetMouseButton(0) && Time.time - gunShootDelay > lastGunShoot)
        {
            //DebugMsg("Left-click");
            ShootProjectile(entityVehicle.gunLauncher, "vehicleGun", "Weapons/Ranged/AK47/ak47_fire_start", true);
            lastGunShoot = Time.time;
        }
        if (entityVehicle.HasExplosiveLauncher() && Input.GetMouseButton(1) && Time.time - missileShootDelay > lastMissileShoot)
        {
            //DebugMsg("Right-click");
            ShootProjectile(entityVehicle.missileLauncher, "vehicleExplosiveLauncher", "Weapons/Ranged/M136/m136_fire", false);
            lastMissileShoot = Time.time;
        }
    }
Exemple #13
0
    public override void Execute(MinEventParams _params)
    {
        EntityPlayerLocal entityPlayer = _params.Self as EntityPlayerLocal;

        if (_params.Self as EntityPlayerLocal != null && this.CreateItem != null && this.CreateItemCount > 0)
        {
            ItemStack itemStack = new ItemStack(ItemClass.GetItem(this.CreateItem, false), this.CreateItemCount);
            if (!LocalPlayerUI.GetUIForPlayer(entityPlayer).xui.PlayerInventory.AddItem(itemStack, true))
            {
                entityPlayer.world.gameManager.ItemDropServer(itemStack, entityPlayer.GetPosition(), Vector3.zero, -1, 60f, false);
            }
        }
    }
    /**
     * When the player activates this entityclass with an empty hand, try to pick it up.
     */

    public override void Kill(DamageResponse _dmgResponse)
    {
        if (_dmgResponse.Source.getEntityId() == -1)
        {
            base.Kill(_dmgResponse);
            Log.Warning("Killer was not a player.");
            return;
        }

        EntityPlayerLocal entityPlayerLocal = GameManager.Instance.World.GetLocalPlayerFromID(_dmgResponse.Source.getEntityId()) as EntityPlayerLocal;

        if (!(entityPlayerLocal is EntityPlayerLocal))
        {
            base.Kill(_dmgResponse);
            Log.Warning("Killer was an entity, but not a player.");
            return;
        }

        LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(entityPlayerLocal);

        if (uiforPlayer.xui.isUsingItemActionEntryUse)
        {
            base.Kill(_dmgResponse);
            Log.Warning("XUI interfering.");
            return;
        }

        ItemStack pickup = new ItemStack(this.itemReturned, 1);

        if (!entityPlayerLocal.inventory.CanTakeItem(pickup) & !entityPlayerLocal.bag.CanTakeItem(pickup))
        {
            base.Kill(_dmgResponse);
            Log.Warning("Canot take item - no room in inventory.");
            return;
        }

        Log.Out("Player is holding: " + entityPlayerLocal.inventory.holdingItem.GetItemName());
        if (entityPlayerLocal.inventory.holdingItem.GetItemName() == "meleeHandPlayer")
        {
            Log.Out("Server, despawn the entity.");
            GameManager.Instance.World.RemoveEntity(this.entityId, EnumRemoveEntityReason.Killed);

            Log.Out("Player, add the item.");
            entityPlayerLocal.inventory.AddItem(pickup);
            return;
        }

        Log.Warning("Cannot activate.");
        base.Kill(_dmgResponse);
        return;
    }
Exemple #15
0
    public override bool OnEntityActivated(int _indexInBlockActivationCommands, Vector3i _tePos, EntityAlive _entityFocusing)
    {
        // set the IsBusy flag, so it won't wander away when you are talking to it.
        this.emodel.avatarController.SetBool("IsBusy", true);

        // Look at the entity that is talking to you.
        this.SetLookPosition(_entityFocusing.getHeadPosition());

        // Add a reference for the dialog otherEntitySDX to the UI, since the respondent doesn't always carry forward
        LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(_entityFocusing as EntityPlayerLocal);

        uiforPlayer.xui.Dialog.otherEntitySDX = this;
        base.OnEntityActivated(_indexInBlockActivationCommands, _tePos, _entityFocusing);


        return(true);
    }
Exemple #16
0
    public override void PerformAction(EntityPlayer player)
    {
        if (string.IsNullOrEmpty(Value))
        {
            Value = "1";
        }

        int flValue = 1;

        int.TryParse(Value, out flValue);

        LocalPlayerUI        uiforPlayer     = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal);
        XUiM_PlayerInventory playerInventory = uiforPlayer.xui.PlayerInventory;

        ItemStack itemStack = new ItemStack(ItemClass.GetItem(ID, false), flValue);

        playerInventory.RemoveItem(itemStack);
    }
Exemple #17
0
    // Adaptation of GameUtils.WZ(ItemActionAttackData itemActionAttackData, ItemValue itemValue, int num, float num2, string text, bool flag = true).
    // .WZ is obfuscated if will be named different on your machine.
    public void AddHarvestItemToInventory(ItemValue itemValue, int num, float num2, string text)
    {
        //string msg = "Harvest: " + itemValue.ItemClass.GetItemName();
        if (itemValue == null || itemValue.ItemClass == null || (itemValue.ItemClass.GetItemName() == "yuccaFibers" && !harvestBlocks.Contains("grass")))
        {
            //DebugMsg(msg += " (NOT HARVESTED)");
            return;
        }
        //DebugMsg(msg);

        if (UnityEngine.Random.value <= num2 && num > 0)
        {
            ItemStack itemStack         = new ItemStack(itemValue, num);
            bool      addedToVehicleInv = false;
            if (harvestToVehicleInventory && entityVehicle.HasStorage())
            {
                //addedToVehicleInv = entityVehicle.xuiC_VehicleContainer.AddItem(itemStack);
                //XUiC_VehicleContainer vehicleContainer = entityVehicle.GetVehicleContainer();
                //XUiC_VehicleContainer vehicleContainer = EntityCustomVehicle.GetVehicleContainer(entityVehicle, entityVehicle.player, entityVehicle.vehicleXuiName);
                //if (vehicleContainer != null)
                if (entityVehicle.xuiC_VehicleContainer != null)
                {
                    //addedToVehicleInv = entityVehicle.inventory.AddItem(itemStack);
                    //addedToVehicleInv = vehicleContainer.AddItem(itemStack);
                    addedToVehicleInv = entityVehicle.xuiC_VehicleContainer.AddItem(itemStack);
                }
            }
            if (!addedToVehicleInv)
            {
                LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(entityVehicle.player);
                //if (!entityVehicle.playerInventory.AddItem(itemStack, true))
                //if (!entityVehicle.player.inventory.AddItem(itemStack))
                if (!uiforPlayer.xui.PlayerInventory.AddItem(itemStack, true))
                {
                    GameManager.Instance.ItemDropServer(new ItemStack(itemValue, num), entityVehicle.player.GetPosition(), Vector3.zero, entityVehicle.player.GetInstanceID(), 60f, false);
                }
            }
            // The harvesting XP is only added when destroyed blocks are also harvested and when HarvestXPFactor xml property > 0.
            if (harvestXPFactor != 0)
            {
                entityVehicle.player.AddExp(Mathf.RoundToInt(itemStack.itemValue.ItemClass.MadeOfMaterial.Experience * (float)num * harvestXPFactor));
            }
        }
    }
Exemple #18
0
    private void EventData_Event(object obj)
    {
        World world = GameManager.Instance.World;

        var eventData = obj as TimerEventData;

        object[] objArray = (object[])eventData.Data;

        int        _clrIdx    = (int)objArray[0];
        BlockValue blockValue = (BlockValue)objArray[1];

        Vector3i   vector3i = (Vector3i)objArray[2];
        BlockValue block    = world.GetBlock(vector3i);

        EntityPlayerLocal entityPlayerLocal = objArray[3] as EntityPlayerLocal;

        if (block.damage > 0)
        {
            GameManager.ShowTooltipWithAlert(entityPlayerLocal, Localization.Get("ttRepairBeforePickup", string.Empty), "ui_denied");
        }
        else if (block.type != blockValue.type)
        {
            GameManager.ShowTooltipWithAlert(entityPlayerLocal, Localization.Get("ttBlockMissingPickup", string.Empty), "ui_denied");
        }
        else
        {
            TileEntitySecureLootContainer tileEntity = world.GetTileEntity(_clrIdx, vector3i) as TileEntitySecureLootContainer;
            if (tileEntity.IsUserAccessing())
            {
                GameManager.ShowTooltipWithAlert(entityPlayerLocal, Localization.Get("ttCantPickupInUse", string.Empty), "ui_denied");
            }
            else
            {
                LocalPlayerUI uiForPlayer = LocalPlayerUI.GetUIForPlayer(entityPlayerLocal);
                ItemStack     itemStack   = new ItemStack(block.ToItemValue(), 1);
                if (!uiForPlayer.xui.PlayerInventory.AddItem(itemStack, true))
                {
                    uiForPlayer.xui.PlayerInventory.DropItem(itemStack);
                }
                world.SetBlockRPC(_clrIdx, vector3i, BlockValue.Air);
            }
        }
    }
    public override void PerformAction(EntityPlayer player)
    {
        LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal);
        // The respondent is an EntityNPC, and we don't have that. Check for the patch scripted otherEntitySDX.
        Entity respondent = uiforPlayer.xui.Dialog.Respondent;

        if (respondent == null)
        {
            respondent = uiforPlayer.xui.Dialog.otherEntitySDX;
        }

        if (respondent != null)
        {
            EntityAliveSDX myEntity = player.world.GetEntity(respondent.entityId) as EntityAliveSDX;
            if (myEntity != null)
            {
                myEntity.ExecuteCMD(base.ID, player);
            }
        }
    }
Exemple #20
0
    /**
     * Called when a block is destroyed by an entity. It cam be useful for separating things out if needed depending on what
     * entity destroyed it.
     */

    public override bool OnBlockDestroyedBy(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, int _entityId, bool _bUseHarvestTool)
    {
        TileEntityBlockTransformer tileEntityBlockTransformer = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityBlockTransformer;

        if (tileEntityBlockTransformer != null)
        {
            tileEntityBlockTransformer.OnDestroy();
        }
        LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(GameManager.Instance.World.GetEntity(_entityId) as EntityPlayerLocal);

        if (null != uiforPlayer && uiforPlayer.windowManager.IsWindowOpen("looting") && ((XUiC_LootWindow)uiforPlayer.xui.GetWindow("windowLooting").Controller).GetLootBlockPos() == _blockPos)
        {
            uiforPlayer.windowManager.Close("looting");
        }
        if (tileEntityBlockTransformer != null)
        {
            _world.GetGameManager().DropContentOfLootContainerServer(_blockValue, _blockPos, tileEntityBlockTransformer.entityId);
        }
        return(true);
    }
    public static bool Hire(int EntityID, EntityPlayerLocal _player)
    {
        DisplayLog("Hire()");
        bool           result   = false;
        EntityAliveSDX myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAliveSDX;

        if (myEntity == null)
        {
            return(result);
        }

        DisplayLog("Hire(): I have an entity");

        LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(_player as EntityPlayerLocal);

        if (uiforPlayer)
        {
            DisplayLog("Hire(): I have a player.");
            DisplayLog(" The Player wants to hire me for " + GetHireCost(EntityID) + " " + GetHireCurrency(EntityID));
            if (uiforPlayer.xui.PlayerInventory.GetItemCount(GetHireCurrency(EntityID)) >= GetHireCost(EntityID))
            {
                DisplayLog(" The Player has enough currency: " + uiforPlayer.xui.PlayerInventory.GetItemCount(GetHireCurrency(EntityID)));
                // Create the stack of currency
                ItemStack stack = new ItemStack(GetHireCurrency(EntityID), GetHireCost(EntityID));
                DisplayLog(" Removing Item: " + stack.ToString());
                uiforPlayer.xui.PlayerInventory.RemoveItems(new ItemStack[] { stack }, 1);

                // Add the stack of currency to the NPC, and set its orders.
                //myEntity.bag.AddItem(stack);
                SetLeaderAndOwner(EntityID, _player.entityId);
                return(true);
            }
            else
            {
                GameManager.ShowTooltipWithAlert(_player, "You cannot afford me. I want " + GetHireCost(EntityID) + " " + GetHireCurrency(EntityID), "ui_denied");
            }
        }
        return(false);
    }
Exemple #22
0
    public virtual bool Hire(EntityPlayerLocal _player)
    {
        LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(_player as EntityPlayerLocal);

        if (null != uiforPlayer)
        {
            if (uiforPlayer.xui.PlayerInventory.GetItemCount(this.HireCurrency) >= this.HireCost)
            {
                // Create the stack of currency
                ItemStack stack = new ItemStack(this.HireCurrency, this.HireCost);
                uiforPlayer.xui.PlayerInventory.RemoveItems(new ItemStack[] { stack }, 1);

                // Add the stack of currency to the NPC, and set its orders.
                this.bag.AddItem(stack);
                SetOwner(_player);
                return(true);
            }
            else
            {
                GameManager.ShowTooltipWithAlert(_player, "You cannot afford me. I want " + this.HireCost + " " + this.HireCurrency, "ui_denied");
            }
        }
        return(false);
    }
    public override void PerformAction(EntityPlayer player)
    {
        LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal);

        uiforPlayer.xui.currentToolTip.ToolTip = ID;
    }
        public static bool Prefix(XUiC_ItemStack __instance, bool ___bLocked, bool ___isDragAndDrop)
        {
            if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature))
            {
                return(true);
            }

            // Make sure we are dealing with legitimate stacks.
            if (__instance.ItemStack.IsEmpty())
            {
                return(true);
            }

            if (__instance.ItemStack.itemValue == null)
            {
                return(true);
            }

            if (___bLocked && ___isDragAndDrop)
            {
                return(true);
            }

            // Reset the durability
            //__instance.durability.IsVisible = false;

            // If the item class has a SpoilageTime, that means it can spoil over time.
            if (__instance.ItemStack.itemValue.ItemClass != null && __instance.ItemStack.itemValue.ItemClass.Properties.Contains("Spoilable"))
            {
                String strDisplay        = "XUiC_ItemStack: " + __instance.ItemStack.itemValue.ItemClass.GetItemName();
                float  DegradationMax    = 0f;
                float  DegradationPerUse = 0f;

                if (__instance.ItemStack.itemValue.ItemClass.Properties.Contains("SpoilageMax"))
                {
                    DegradationMax = __instance.ItemStack.itemValue.ItemClass.Properties.GetFloat("SpoilageMax");
                }

                if (__instance.ItemStack.itemValue.ItemClass.Properties.Contains("SpoilagePerTick"))
                {
                    DegradationPerUse = __instance.ItemStack.itemValue.ItemClass.Properties.GetFloat("SpoilagePerTick");
                }

                // By default, have a spoiler hit every 100 ticks, but allow it to be over-rideable in the xml.
                int TickPerLoss = 100;

                // Check if there's a Global Ticks Per Loss Set
                BlockValue ConfigurationBlock = Block.GetBlockValue("ConfigFeatureBlock");
                TickPerLoss = int.Parse(Configuration.GetPropertyValue("FoodSpoilage", "TickPerLoss"));

                // Check if there's a item-specific TickPerLoss
                if (__instance.ItemStack.itemValue.ItemClass.Properties.Contains("TickPerLoss"))
                {
                    TickPerLoss = __instance.ItemStack.itemValue.ItemClass.Properties.GetInt("TickPerLoss");
                }
                strDisplay += " Ticks Per Loss: " + TickPerLoss;

                // NextSpoilageTick will hold the world time + how many ticks until the next spoilage.
                if (__instance.ItemStack.itemValue.NextSpoilageTick == 0)
                {
                    __instance.ItemStack.itemValue.NextSpoilageTick = (int)GameManager.Instance.World.GetWorldTime() + TickPerLoss;
                }

                // Throttles the amount of times it'll trigger the spoilage, based on the TickPerLoss
                if (__instance.ItemStack.itemValue.NextSpoilageTick < (int)GameManager.Instance.World.GetWorldTime())
                {
                    // How much spoilage to apply
                    float PerUse = DegradationPerUse;

                    // Check if there's a player involved, which could change the spoilage rate.
                    //EntityPlayerLocal player = GameManager.Instance.World.GetPrimaryPlayer();
                    //if(player)
                    //   PerUse = EffectManager.GetValue(PassiveEffects.DegradationPerUse, __instance.ItemStack.itemValue, 1f, player, null, __instance.ItemStack.itemValue.ItemClass.ItemTags, true, true, true, true, 1, true);
                    //else
                    //   PerUse = EffectManager.GetValue(PassiveEffects.DegradationPerUse, __instance.ItemStack.itemValue, 1f, null, null, __instance.ItemStack.itemValue.ItemClass.ItemTags, true, true, true, true, 1, true);

                    float BasePerUse = PerUse;
                    strDisplay += " Base Spoil: " + PerUse;

                    float containerValue = 0;
                    // Additional Spoiler flags to increase or decrease the spoil rate
                    switch (__instance.StackLocation)
                    {
                    case XUiC_ItemStack.StackLocationTypes.ToolBelt:      // Tool belt Storage check
                        containerValue = float.Parse(Configuration.GetPropertyValue("FoodSpoilage", "Toolbelt"));
                        strDisplay    += " Storage Type: Tool Belt ( " + containerValue + " )";
                        PerUse        += containerValue;

                        break;

                    case XUiC_ItemStack.StackLocationTypes.Backpack:            // Back pack storage check
                        containerValue = float.Parse(Configuration.GetPropertyValue("FoodSpoilage", "Backpack"));
                        strDisplay    += " Storage Type: Backpack ( " + containerValue + " )";
                        PerUse        += containerValue;

                        break;

                    case XUiC_ItemStack.StackLocationTypes.LootContainer:        // Loot Container Storage check
                        TileEntityLootContainer container = __instance.xui.lootContainer;
                        if (container != null)
                        {
                            BlockValue Container         = GameManager.Instance.World.GetBlock(container.ToWorldPos());
                            String     lootContainerName = Localization.Get(Block.list[Container.type].GetBlockName());
                            strDisplay += " " + lootContainerName;

                            containerValue = float.Parse(Configuration.GetPropertyValue("FoodSpoilage", "Container"));
                            strDisplay    += " Storage Type: Container ( " + containerValue + " )";
                            PerUse        += containerValue;

                            if (Container.Block.Properties.Contains("PreserveBonus"))
                            {
                                strDisplay += " Preservation Bonus ( " + Container.Block.Properties.GetFloat("PreserveBonus") + " )";
                                PerUse     -= Container.Block.Properties.GetFloat("PreserveBonus");
                            }
                        }
                        else
                        {
                            strDisplay += " Storage Type: Container ( Undefined Configuration Block: +10 )";
                            PerUse     += 10;
                        }

                        break;

                    case XUiC_ItemStack.StackLocationTypes.Creative:      // Ignore Creative Containers
                        return(true);

                    default:
                        containerValue = float.Parse(Configuration.GetPropertyValue("FoodSpoilage", "Container"));
                        strDisplay    += " Storage Type: Generic ( Default Container) ( " + containerValue + " )";
                        PerUse        += containerValue;
                        break;
                    }


                    strDisplay += " Spoiled This Tick: " + (PerUse - BasePerUse);
                    float MinimumSpoilage = float.Parse(Configuration.GetPropertyValue("FoodSpoilage", "MinimumSpoilage"));
                    MinimumSpoilage = Math.Max(0.1f, MinimumSpoilage);

                    // Worse case scenario, no matter what, Spoilage will increment.
                    if (PerUse <= MinimumSpoilage)
                    {
                        strDisplay += " Minimum spoilage Detected (PerUse: " + PerUse + " Minimum: " + MinimumSpoilage + " )";
                        PerUse      = MinimumSpoilage;
                    }
                    // Calculate how many Spoils we may have missed over time. If we left our base and came back to our storage box, this will help accurately determine how much
                    // spoilage should apply.
                    String temp = "World Time: " + (int)GameManager.Instance.World.GetWorldTime() + " Minus NextSpoilageTick: " + __instance.ItemStack.itemValue.NextSpoilageTick + " Tick Per Loss: " + TickPerLoss;
                    AdvLogging.DisplayLog(AdvFeatureClass, temp);

                    int TotalSpoilageMultiplier = (int)(GameManager.Instance.World.GetWorldTime() - __instance.ItemStack.itemValue.NextSpoilageTick) / TickPerLoss;
                    if (TotalSpoilageMultiplier == 0)
                    {
                        TotalSpoilageMultiplier = 1;
                    }

                    float TotalSpoilage = PerUse * TotalSpoilageMultiplier;
                    strDisplay += " Spoilage Ticks Missed: " + TotalSpoilageMultiplier;
                    strDisplay += " Total Spoilage: " + TotalSpoilage;
                    __instance.ItemStack.itemValue.CurrentSpoilage += TotalSpoilage;

                    strDisplay += " Next Spoilage Tick: " + (int)GameManager.Instance.World.GetWorldTime() + TickPerLoss;
                    strDisplay += " Recorded Spoilage: " + __instance.ItemStack.itemValue.CurrentSpoilage;
                    AdvLogging.DisplayLog(AdvFeatureClass, strDisplay);

                    // Update the NextSpoilageTick value
                    __instance.ItemStack.itemValue.NextSpoilageTick = (int)GameManager.Instance.World.GetWorldTime() + TickPerLoss;
                    __instance.ItemStack.itemValue.NextSpoilageTick = (int)GameManager.Instance.World.GetWorldTime() + TickPerLoss;

                    // If the spoil time is is greater than the degradation, loop around the stack, removing each layer of items.
                    while (DegradationMax <= __instance.ItemStack.itemValue.CurrentSpoilage)
                    //if(DegradationMax <= __instance.ItemStack.itemValue.CurrentSpoilage)
                    {
                        // If not defined, set the foodRottingFlesh as a spoiled product. Otherwise use the global / item.
                        String strSpoiledItem = Configuration.GetPropertyValue("FoodSpoilage", "SpoiledItem");
                        if (string.IsNullOrEmpty(strSpoiledItem))
                        {
                            strSpoiledItem = "foodRottingFlesh";
                        }

                        if (__instance.ItemStack.itemValue.ItemClass.Properties.Contains("SpoiledItem"))
                        {
                            strSpoiledItem = __instance.ItemStack.itemValue.ItemClass.Properties.GetString("SpoiledItem");
                        }



                        //EntityPlayerLocal player = __instance.xui.playerUI.entityPlayer;
                        EntityPlayerLocal player = GameManager.Instance.World.GetPrimaryPlayer();
                        if (player)
                        {
                            int Count = 1;

                            if (Configuration.CheckFeatureStatus(AdvFeatureClass, "FullStackSpoil"))
                            {
                                AdvLogging.DisplayLog(AdvFeatureClass, __instance.ItemStack.itemValue.ItemClass.GetItemName() + ":Full Stack Spoil");
                                Count = __instance.ItemStack.count;
                                __instance.ItemStack = new ItemStack(ItemClass.GetItem(strSpoiledItem, false), Count);
                                break;
                            }
                            ItemStack itemStack = new ItemStack(ItemClass.GetItem(strSpoiledItem, false), Count);

                            if (itemStack.itemValue.ItemClass.GetItemName() != __instance.ItemStack.itemValue.ItemClass.GetItemName())
                            {
                                if (!LocalPlayerUI.GetUIForPlayer(player).xui.PlayerInventory.AddItem(itemStack, true))
                                {
                                    player.world.gameManager.ItemDropServer(itemStack, player.GetPosition(), Vector3.zero, -1, 60f, false);
                                }
                            }
                        }

                        if (__instance.ItemStack.count > 2)
                        {
                            AdvLogging.DisplayLog(AdvFeatureClass, __instance.ItemStack.itemValue.ItemClass.GetItemName() + ": Reducing Stack by 1");
                            __instance.ItemStack.count--;
                            __instance.ItemStack.itemValue.CurrentSpoilage -= DegradationMax;
                        }
                        else
                        {
                            AdvLogging.DisplayLog(AdvFeatureClass, __instance.ItemStack.itemValue.ItemClass.GetItemName() + ": Stack Depleted. Removing.");
                            __instance.ItemStack = new ItemStack(ItemValue.None.Clone(), 0);
                            break;  // Nothing more to spoil
                        }
                        // break;
                    }
                    __instance.ForceRefreshItemStack();
                }
            }

            return(true);
        }
    public static bool ExecuteCMD(int EntityID, String strCommand, EntityPlayer player)
    {
        DisplayLog("ExecuteCMD: " + strCommand);
        EntityAliveSDX myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAliveSDX;

        if (myEntity == null)
        {
            return(false);
        }

        LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal);

        Vector3 position = myEntity.position;

        // Restore it's walk speed to default.
        myEntity.RestoreSpeed();

        switch (strCommand)
        {
        case "TellMe":
            //XUiC_TipWindow.ShowTip(myEntity.ToString(), XUiM_Player.GetPlayer() as EntityPlayerLocal,null);
            GameManager.ShowTooltipWithAlert(player as EntityPlayerLocal, myEntity.ToString() + "\n\n\n\n\n", "ui_denied");
            // uiforPlayer.windowManager.Open("EntityInformation", true, false, true);
            break;

        case "ShowAffection":
            GameManager.ShowTooltipWithAlert(player as EntityPlayerLocal, "You gentle scratch and stroke the side of the animal.", "");
            break;

        case "FollowMe":
            SetLeader(EntityID, player.entityId);
            SetCurrentOrder(EntityID, Orders.Follow);
            myEntity.moveSpeed      = player.moveSpeed;
            myEntity.moveSpeedAggro = player.moveSpeedAggro;

            break;

        case "StayHere":
            SetCurrentOrder(EntityID, Orders.Stay);
            myEntity.GuardPosition = position;
            myEntity.moveHelper.Stop();
            break;

        case "GuardHere":
            SetCurrentOrder(EntityID, Orders.Stay);
            myEntity.SetLookPosition(player.GetLookVector());
            myEntity.GuardPosition = position;
            myEntity.moveHelper.Stop();
            myEntity.GuardLookPosition = player.GetLookVector();
            break;

        case "Wander":
            SetCurrentOrder(EntityID, Orders.Wander);
            break;

        case "SetPatrol":
            SetLeader(EntityID, player.entityId);
            SetCurrentOrder(EntityID, Orders.SetPatrolPoint);
            myEntity.moveSpeed      = player.moveSpeed;
            myEntity.moveSpeedAggro = player.moveSpeedAggro;
            myEntity.PatrolCoordinates.Clear();     // Clear the existing point.
            break;

        case "Patrol":
            SetCurrentOrder(EntityID, Orders.Patrol);
            break;

        case "Hire":
            bool result = Hire(EntityID, player as EntityPlayerLocal);
            break;

        case "OpenInventory":
            GameManager.Instance.TELockServer(0, myEntity.GetBlockPosition(), EntityID, player.entityId);
            uiforPlayer.windowManager.CloseAllOpenWindows(null, false);
            if (myEntity.lootContainer == null)
            {
                DisplayLog(" Loot Container is null");
            }
            else
            {
                DisplayLog(" Get Open Time");
                DisplayLog("Loot Container: " + myEntity.lootContainer.ToString());
                myEntity.lootContainer.lootListIndex = 62;
                DisplayLog(" Loot List: " + myEntity.lootContainer.lootListIndex);

                DisplayLog(myEntity.lootContainer.GetOpenTime().ToString());
                lootContainerOpened(myEntity.lootContainer, uiforPlayer, player.entityId);
            }
            break;

        case "Loot":
            SetCurrentOrder(EntityID, Orders.Loot);
            myEntity.Buffs.RemoveCustomVar("Leader");
            break;

        case "Dismiss":
            SetCurrentOrder(EntityID, Orders.Wander);
            myEntity.Buffs.RemoveCustomVar("Leader");
            myEntity.Buffs.RemoveCustomVar("Owner");
            break;
        }

        return(true);
    }
Exemple #26
0
    public static bool ExecuteCMD(int EntityID, String strCommand, EntityPlayer player)
    {
        String strDisplay = "ExecuteCMD( " + strCommand + " ) to " + EntityID + " From " + player.DebugNameInfo;

        AdvLogging.DisplayLog(AdvFeatureClass, strDisplay);

        EntityAliveSDX myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAliveSDX;

        if (myEntity == null)
        {
            return(false);
        }

        LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal);

        Vector3 position = myEntity.position;

        // Restore it's walk speed to default.
        myEntity.RestoreSpeed();

        switch (strCommand)
        {
        case "TellMe":
            GameManager.ShowTooltipWithAlert(player as EntityPlayerLocal, myEntity.ToString() + "\n\n\n\n\n", "ui_denied");
            AdvLogging.DisplayLog(AdvFeatureClass, "\n\nBuffs:");
            foreach (var Buff in myEntity.Buffs.ActiveBuffs)
            {
                AdvLogging.DisplayLog(AdvFeatureClass, "\t" + Buff.BuffName);
            }

            AdvLogging.DisplayLog(AdvFeatureClass, myEntity.ToString());
            AdvLogging.DisplayLog(AdvFeatureClass, "Body Damage: ");
            AdvLogging.DisplayLog(AdvFeatureClass, "\t Has Right Leg? " + myEntity.bodyDamage.HasRightLeg);
            AdvLogging.DisplayLog(AdvFeatureClass, "\t Has Left Leg? " + myEntity.bodyDamage.HasLeftLeg);
            AdvLogging.DisplayLog(AdvFeatureClass, "\t Has Limbs? " + myEntity.bodyDamage.HasLimbs);
            AdvLogging.DisplayLog(AdvFeatureClass, "\t Arm or Leg missing? " + myEntity.bodyDamage.IsAnyArmOrLegMissing);
            AdvLogging.DisplayLog(AdvFeatureClass, "\t Has any leg missing? " + myEntity.bodyDamage.IsAnyLegMissing);
            bool LegDamageTrigger = false;
            myEntity.emodel.avatarController.TryGetTrigger("LegDamageTrigger", out LegDamageTrigger);
            AdvLogging.DisplayLog(AdvFeatureClass, "\t Leg Damage Trigger? " + LegDamageTrigger);
            break;

        case "ShowAffection":
            GameManager.ShowTooltipWithAlert(player as EntityPlayerLocal, "You gentle scratch and stroke the side of the animal.", "");
            break;

        case "FollowMe":
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Setting Leader");
            SetLeader(EntityID, player.entityId);
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Setting Order");
            SetCurrentOrder(EntityID, Orders.Follow);
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Adjusting Speeds");
            myEntity.moveSpeed      = player.moveSpeed;
            myEntity.moveSpeedAggro = player.moveSpeedAggro;
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Done with Order");
            break;

        case "StayHere":
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Setting Order");
            SetCurrentOrder(EntityID, Orders.Stay);
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Setting Position");
            myEntity.GuardPosition = position;
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Stopping Move Helper()");
            if (myEntity.moveHelper != null)     // No move helper on the client when on Dedi
            {
                myEntity.moveHelper.Stop();
            }
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Done with Order");

            break;

        case "GuardHere":
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Setting Order");
            SetCurrentOrder(EntityID, Orders.Stay);
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Setting Look Direction");

            myEntity.SetLookPosition(player.GetLookVector());
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Setting Position");

            myEntity.GuardPosition = position;
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Stopping Move Helper()");

            if (myEntity.moveHelper != null)     // No move helper on the client when on Dedi
            {
                myEntity.moveHelper.Stop();
            }
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Setting Guard Look");
            myEntity.GuardLookPosition = player.GetLookVector();
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Done with Order");

            break;

        case "Wander":
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Setting Order");
            SetCurrentOrder(EntityID, Orders.Wander);
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Done with Order");

            break;

        case "SetPatrol":
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Setting Order");
            SetLeader(EntityID, player.entityId);
            SetCurrentOrder(EntityID, Orders.SetPatrolPoint);
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Setting Move Speed");
            myEntity.moveSpeed      = player.moveSpeed;
            myEntity.moveSpeedAggro = player.moveSpeedAggro;
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Resetting Patrol Points");

            myEntity.PatrolCoordinates.Clear();     // Clear the existing point
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Done with Order");

            break;

        case "Patrol":
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Setting Order");
            SetCurrentOrder(EntityID, Orders.Patrol);
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Done with Order");

            break;

        case "Hire":
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Opening Hire ");
            bool result = Hire(EntityID, player as EntityPlayerLocal);
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Done with Hire");

            break;

        case "OpenInventory":
            AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Setting Order Open Inventory");

            //      GameManager.Instance.TELockServer(0, myEntity.GetBlockPosition(), EntityID, player.entityId);
            //       uiforPlayer.windowManager.CloseAllOpenWindows(null, false);
            if (myEntity.lootContainer == null)
            {
                AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Loot Container is null");
            }

            else
            {
                AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Loot Container: " + myEntity.lootContainer.ToString());
                myEntity.lootContainer.lootListIndex = 62;
                AdvLogging.DisplayLog(AdvFeatureClass, strDisplay + " Opening Loot Container");

                lootContainerOpened(myEntity.lootContainer, uiforPlayer, player.entityId);
            }
            break;

        case "Loot":
            SetCurrentOrder(EntityID, Orders.Loot);
            myEntity.Buffs.RemoveCustomVar("Leader");
            break;

        case "Dismiss":
            SetCurrentOrder(EntityID, Orders.Wander);
            myEntity.Buffs.RemoveCustomVar("Leader");
            myEntity.Buffs.RemoveCustomVar("Owner");
            break;
        }

        return(true);
    }
    void Update()
    {
        if (GameManager.IsDedicatedServer)
        {
            return;
        }

        if (entityVehicle == null || entityVehicle.player == null || entityVehicle.cameraOffset == null)
        {
            InitController();
            return;
        }

        LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(entityVehicle.player);

        //if (!entityVehicle.hasDriver || GameManager.Instance.IsPaused() || GameManager.Instance.m_GUIConsole.isInputActive || entityVehicle.uiforPlayer.windowManager.IsModalWindowOpen())
        if (!entityVehicle.hasDriver || GameManager.Instance.IsPaused() || GameManager.Instance.m_GUIConsole.isInputActive || uiforPlayer.windowManager.IsModalWindowOpen())
        {
            return;
        }

        // toggle 1st-3rd person view
        if (Input.GetKey(KeyCode.Home) && Time.time - 1.0f > lastCamToggle)
        {
            if (is3rdPersonView)
            {
                ToggleFirstAnd3rdPersonView(true, true);
            }
            else
            {
                ToggleFirstAnd3rdPersonView(false, true);
            }
        }

        // 3rd person view Zoom in-out
        if (is3rdPersonView && entityVehicle.player != null)
        {
            if (Input.GetAxis("Mouse ScrollWheel") > 0f) // forward
            {
                if (newThirdPcameraOffset.z >= entityVehicle.cameraOffset.z)
                {
                    newThirdPcameraOffset.z += Mathf.Lerp(1.0f, 0.02f, thirdPcamLerpMult);
                }
                else
                {
                    newThirdPcameraOffset.z += Mathf.Lerp(1.0f, 5.0f, thirdPcamLerpMult);
                }
                //DebugMsg("thirdPcamLerpMult = " + thirdPcamLerpMult.ToString("0.0000"));
            }
            else if (Input.GetAxis("Mouse ScrollWheel") < 0f) // backwards
            {
                if (newThirdPcameraOffset.z >= entityVehicle.cameraOffset.z)
                {
                    newThirdPcameraOffset.z -= Mathf.Lerp(1.0f, 0.2f, thirdPcamLerpMult);
                }
                else
                {
                    newThirdPcameraOffset.z -= Mathf.Lerp(1.0f, 5.0f, thirdPcamLerpMult);
                }
                //DebugMsg("thirdPcamLerpMult = " + thirdPcamLerpMult.ToString("0.0000"));
            }

            if (newThirdPcameraOffset.z > entityVehicle.cameraOffset.z / 3.0f)
            {
                newThirdPcameraOffset.z = entityVehicle.cameraOffset.z / 3.0f;
            }

            if (newThirdPcameraOffset.z >= entityVehicle.cameraOffset.z)
            {
                thirdPcamLerpMult       = CustomVehiclesUtils.GetRatio(Mathf.Clamp(newThirdPcameraOffset.z, entityVehicle.cameraOffset.z, entityVehicle.cameraOffset.z / 3.0f), entityVehicle.cameraOffset.z, entityVehicle.cameraOffset.z / 3.0f);
                newThirdPcameraOffset.y = Mathf.Lerp(entityVehicle.cameraOffset.y, entityVehicle.cameraOffset.y + Mathf.Clamp(Mathf.Abs(entityVehicle.cameraOffset.y) * 2.0f, 0.5f, 2.0f), thirdPcamLerpMult);
            }
            else
            {
                thirdPcamLerpMult       = 1f - CustomVehiclesUtils.GetRatio(Mathf.Clamp(newThirdPcameraOffset.z, -50.0f, entityVehicle.cameraOffset.z), -50.0f, entityVehicle.cameraOffset.z);
                newThirdPcameraOffset.y = Mathf.Lerp(entityVehicle.cameraOffset.y, entityVehicle.cameraOffset.y + 15.0f, thirdPcamLerpMult);
            }

            entityVehicle.player.vp_FPCamera.Position3rdPersonOffset = newThirdPcameraOffset;
        }
    }
Exemple #28
0
    public virtual bool ExecuteCMD(String strCommand, EntityPlayer player)
    {
        Debug.Log(GetType().ToString() + " : Command: " + strCommand);
        LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal);

        // Restore it's walk speed to default.
        RestoreSpeed();

        switch (strCommand)
        {
        case "ShowMe":
            GameManager.ShowTooltipWithAlert(player as EntityPlayerLocal, this.ToString() + "\n\n\n\n\n", "ui_denied");
            break;

        case "ShowAffection":
            GameManager.ShowTooltipWithAlert(player as EntityPlayerLocal, "You gentle scratch and stroke the side of the animal.", "");
            break;

        case "FollowMe":
            this.Buffs.SetCustomVar("Leader", player.entityId, true);
            this.Buffs.SetCustomVar("CurrentOrder", (float)EntityAliveSDX.Orders.Follow, true);
            this.moveSpeed      = player.moveSpeed;
            this.moveSpeedAggro = player.moveSpeedAggro;

            break;

        case "StayHere":
            this.Buffs.SetCustomVar("CurrentOrder", (float)EntityAliveSDX.Orders.Stay, true);
            this.GuardPosition = this.position;
            this.moveHelper.Stop();
            break;

        case "GuardHere":
            this.Buffs.SetCustomVar("CurrentOrder", (float)EntityAliveSDX.Orders.Stay, true);
            this.SetLookPosition(player.GetLookVector());
            this.GuardPosition = this.position;
            this.moveHelper.Stop();
            this.GuardLookPosition = player.GetLookVector();
            break;

        case "Wander":
            this.Buffs.SetCustomVar("CurrentOrder", (float)EntityAliveSDX.Orders.Wander, true);
            break;

        case "SetPatrol":
            this.Buffs.SetCustomVar("Leader", player.entityId, true);
            this.Buffs.SetCustomVar("CurrentOrder", (float)EntityAliveSDX.Orders.SetPatrolPoint, true);
            this.moveSpeed      = player.moveSpeed;
            this.moveSpeedAggro = player.moveSpeedAggro;
            this.PatrolCoordinates.Clear();     // Clear the existing point.
            break;

        case "Patrol":
            this.Buffs.SetCustomVar("CurrentOrder", (float)EntityAliveSDX.Orders.Patrol, true);
            break;

        case "Hire":
            bool result = this.Hire(player as EntityPlayerLocal);
            break;

        case "OpenInventory":
            GameManager.Instance.TELockServer(0, this.GetBlockPosition(), this.entityId, player.entityId);
            uiforPlayer.windowManager.CloseAllOpenWindows(null, false);
            if (this.lootContainer == null)
            {
                DisplayLog(" Loot Container is null");
            }

            DisplayLog(" Get Open Time");
            DisplayLog("Loot Container: " + this.lootContainer.ToString());
            this.lootContainer.lootListIndex = 62;
            DisplayLog(" Loot List: " + this.lootContainer.lootListIndex);

            DisplayLog(this.lootContainer.GetOpenTime().ToString());
            // GameManager.Instance.lootContainerOpened((TileEntityLootContainer)this.lootContainer, uiforPlayer, player.entityId);

            break;

        case "Loot":
            this.Buffs.SetCustomVar("CurrentOrder", (float)EntityAliveSDX.Orders.Loot, true);
            break;
        }

        if (this.Buffs.HasCustomVar("CurrentOrder"))
        {
            this.currentOrder = (Orders)this.Buffs.GetCustomVar("CurrentOrder");
            DisplayLog(" Setting Current Order: " + this.currentOrder);
        }
        return(true);
    }
        public static bool Prefix(ItemActionEntryScrap __instance)
        {
            // Check if this feature is enabled.
            if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature))
            {
                return(true);
            }
            #region vanilla_code
            XUi            xui            = __instance.ItemController.xui;
            XUiC_ItemStack xuiC_ItemStack = (XUiC_ItemStack)__instance.ItemController;

            ItemStack itemStack       = xuiC_ItemStack.ItemStack.Clone();
            Recipe    scrapableRecipe = CraftingManager.GetScrapableRecipe(itemStack.itemValue, itemStack.count);
            if (scrapableRecipe == null)
            {
                return(true);
            }

            XUiController xuiController = __instance.ItemController.xui.FindWindowGroupByName("workstation_workbench");
            if (xuiController == null || !xuiController.WindowGroup.isShowing)
            {
                xuiController = xui.FindWindowGroupByName("crafting");
            }

            XUiC_CraftingWindowGroup childByType = xuiController.GetChildByType <XUiC_CraftingWindowGroup>();
            if (childByType == null)
            {
                return(true);
            }
            #endregion  vanilla_code

            LocalPlayerUI    uiforPlayer = LocalPlayerUI.GetUIForPlayer(__instance.ItemController.xui.playerUI.entityPlayer);
            List <ItemStack> scrapItems  = new List <ItemStack>();

            ItemClass forId = ItemClass.GetForId(itemStack.itemValue.type);
            // Check if ScrapItems is specified
            if (forId.Properties.Classes.ContainsKey("ScrapItems"))
            {
                DynamicProperties dynamicProperties3 = forId.Properties.Classes["ScrapItems"];
                scrapItems = ItemsUtilities.ParseProperties(dynamicProperties3);
                ItemsUtilities.Scrap(scrapItems, itemStack, __instance.ItemController);
                return(false);
            }
            else if (forId.Properties.Contains("ScrapItems")) // Support for <property name="ScrapItems" value="resourceWood,0,resourceLeather,2" />
            {
                string strData = forId.Properties.Values["ScrapItems"].ToString();
                scrapItems = ItemsUtilities.ParseProperties(strData);
                ItemsUtilities.Scrap(scrapItems, itemStack, __instance.ItemController);
                return(false);
            }
            // Check if Repair Items is specified, if the ScrapItems wasn't.
            else if (forId.Properties.Classes.ContainsKey("RepairItems"))
            {
                DynamicProperties dynamicProperties3 = forId.Properties.Classes["RepairItems"];
                scrapItems = ItemsUtilities.ParseProperties(dynamicProperties3);
                ItemsUtilities.Scrap(scrapItems, itemStack, __instance.ItemController);
                return(false);
            }
            else if (forId.RepairTools == null || forId.RepairTools.Length <= 0)
            {
                if (CraftingManager.GetRecipe(forId.GetItemName()) == null)
                {
                    return(true);
                }

                if (CraftingManager.GetRecipe(forId.GetItemName()).tags.Test_AnySet(FastTags.Parse("usevanillascrap")))
                {
                    return(true);
                }

                // If there's a recipe, reduce it
                Recipe recipe = ItemsUtilities.GetReducedRecipes(forId.GetItemName(), 2);

                ItemsUtilities.Scrap(recipe.ingredients, itemStack, __instance.ItemController);
                return(false);
            }
            return(true);
        }
        public static void Exec(ClientInfo _cInfo, string _itemNameAndCount)
        {
            Log.Out("[SERVERTOOLS] Test 1");
            if (_cInfo != null && !string.IsNullOrEmpty(_itemNameAndCount))
            {
                try
                {
                    string _itemName = "";
                    int    _count    = 1;
                    if (_itemNameAndCount.Contains(" "))
                    {
                        string _amount = _itemNameAndCount.Split(' ').Last();
                        if (int.TryParse(_amount, out _count))
                        {
                            _itemName = _itemNameAndCount.Replace(" " + _amount, "");
                            Log.Out(string.Format("[SERVERTOOLS] _itemName: {0}", _itemName));
                            ItemClass _class = ItemClass.GetItemClass(_itemName, true);
                            Block     _block = Block.GetBlockByName(_itemName, true);
                            if (_class == null && _block == null)
                            {
                                Log.Out(string.Format("[SERVERTOOLS] invalid item to remove. Item not found: {0}", _itemName));
                                return;
                            }
                            else
                            {
                                Log.Out("[SERVERTOOLS] Test 2. Building local player");
                                EntityPlayerLocal _entityPlayerLocal = BuildLocalPlayer(_cInfo);
                                LocalPlayerUI     uiforPlayer        = LocalPlayerUI.GetUIForPlayer(_entityPlayerLocal);
                                if (uiforPlayer != null)
                                {
                                    Log.Out("[SERVERTOOLS] Test 3. uiforPlayer is not null");
                                }
                                EntityPlayerLocal _localPlayerFromID = GameManager.Instance.World.GetLocalPlayerFromID(_cInfo.entityId);
                                if (_localPlayerFromID != null)
                                {
                                    Log.Out("[SERVERTOOLS] Test 3.5. _localPlayerFromID is not null");
                                }
                                Log.Out("[SERVERTOOLS] Test 4. Adjusting local player bag");
                                EntityPlayerLocal _entityPlayerLocalAdjusted = Adjust(_entityPlayerLocal, _itemName, _count);
                                Log.Out("[SERVERTOOLS] Test 5 Sending package");

                                _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackagePlayerInventory>().Setup(_entityPlayerLocalAdjusted, false, true, false));
                                Log.Out("[SERVERTOOLS] Test 6 Operation complete");
                            }
                        }
                        else
                        {
                            Log.Out(string.Format("[SERVERTOOLS] you must input a valid item count. {0}", _amount));
                            return;
                        }
                    }
                    else
                    {
                        Log.Out(string.Format("[SERVERTOOLS] you must input a valid item name and count. {0}", _itemNameAndCount));
                        return;
                    }
                }
                catch (Exception e)
                {
                    Log.Out(string.Format("[ServerTools] Failed to run ", e.Message));
                }
            }
        }