상속: MonoBehaviour
예제 #1
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// Refund
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        static void Refund(BasePlayer player, BaseEntity entity, RemoveType removeType)
        {
            if (removeType == RemoveType.All)
            {
                return;
            }
            if (refundDeployable && entity.GetComponentInParent <Deployable>() != null)
            {
                Deployable worlditem = entity.GetComponentInParent <Deployable>();
                if (deployedToItem.ContainsKey(worlditem.gameObject.name))
                {
                    player.inventory.GiveItem(deployedToItem[worlditem.gameObject.name], 1, true);
                }
            }
            else if (refundStructure && entity is BuildingBlock)
            {
                BuildingBlock buildingblock = entity as BuildingBlock;
                if (buildingblock.blockDefinition == null)
                {
                    return;
                }

                int buildingblockGrade = (int)buildingblock.grade;
                if (buildingblock.blockDefinition.grades[buildingblockGrade] != null && refundPercentage.ContainsKey(buildingblockGrade.ToString()))
                {
                    decimal           refundRate  = decimal.Parse((string)refundPercentage[buildingblockGrade.ToString()]) / 100.0m;
                    List <ItemAmount> currentCost = buildingblock.blockDefinition.grades[buildingblockGrade].costToBuild as List <ItemAmount>;
                    foreach (ItemAmount ia in currentCost)
                    {
                        player.inventory.GiveItem(ia.itemid, Convert.ToInt32((decimal)ia.amount * refundRate), true);
                    }
                }
            }
        }
예제 #2
0
    private void DoDeploy(RPCMessage msg)
    {
        if (!msg.player.CanInteract())
        {
            return;
        }
        Deployable deployable = GetDeployable();

        if (deployable == null)
        {
            return;
        }
        Ray  ray = msg.read.Ray();
        uint num = msg.read.UInt32();

        if (Interface.CallHook("CanDeployItem", msg.player, this, num) == null)
        {
            if (deployable.toSlot)
            {
                DoDeploy_Slot(deployable, ray, num);
            }
            else
            {
                DoDeploy_Regular(deployable, ray);
            }
        }
    }
예제 #3
0
    public bool CheckPlacement(Deployable deployable, Ray ray, float fDistance)
    {
        RaycastHit raycastHit;
        bool       flag;

        using (TimeWarning timeWarning = TimeWarning.New("Deploy.CheckPlacement", 0.1f))
        {
            if (UnityEngine.Physics.Raycast(ray, out raycastHit, fDistance, 1235288065))
            {
                DeployVolume[] deployVolumeArray = PrefabAttribute.server.FindAll <DeployVolume>(deployable.prefabID);
                Vector3        vector3           = raycastHit.point;
                Quaternion     deployedRotation  = this.GetDeployedRotation(raycastHit.normal, ray.direction);
                if (DeployVolume.Check(vector3, deployedRotation, deployVolumeArray, -1))
                {
                    flag = false;
                }
                else if (this.IsPlacementAngleAcceptable(raycastHit.point, deployedRotation))
                {
                    return(true);
                }
                else
                {
                    flag = false;
                }
            }
            else
            {
                flag = false;
            }
        }
        return(flag);
    }
예제 #4
0
 protected override void AttributeSetup(GameObject rootObj, string name, bool serverside, bool clientside, bool bundling)
 {
     base.AttributeSetup(rootObj, name, serverside, clientside, bundling);
     isBuildingPrivilege = rootObj.GetComponent <BuildingPrivlidge>();
     bounds         = rootObj.GetComponent <BaseEntity>().bounds;
     deployable     = GetComponent <Deployable>();
     placeholder    = GetComponentInChildren <ConstructionPlaceholder>();
     allSockets     = GetComponentsInChildren <Socket_Base>(true);
     allProximities = GetComponentsInChildren <BuildingProximity>(true);
     socketHandle   = GetComponentsInChildren <SocketHandle>(true).FirstOrDefault();
     ConstructionGrade[] components = rootObj.GetComponents <ConstructionGrade>();
     grades = new ConstructionGrade[5];
     ConstructionGrade[] array = components;
     foreach (ConstructionGrade constructionGrade in array)
     {
         constructionGrade.construction = this;
         grades[(int)constructionGrade.gradeBase.type] = constructionGrade;
     }
     for (int j = 0; j < grades.Length; j++)
     {
         if (!(grades[j] == null))
         {
             defaultGrade = grades[j];
             break;
         }
     }
 }
예제 #5
0
 protected override void AttributeSetup(GameObject rootObj, string name, bool serverside, bool clientside, bool bundling)
 {
     base.AttributeSetup(rootObj, name, serverside, clientside, bundling);
     this.isBuildingPrivilege = rootObj.GetComponent <BuildingPrivlidge>();
     this.bounds         = rootObj.GetComponent <BaseEntity>().bounds;
     this.deployable     = base.GetComponent <Deployable>();
     this.placeholder    = base.GetComponentInChildren <ConstructionPlaceholder>();
     this.allSockets     = base.GetComponentsInChildren <Socket_Base>(true);
     this.allProximities = base.GetComponentsInChildren <BuildingProximity>(true);
     this.socketHandle   = base.GetComponentsInChildren <SocketHandle>(true).FirstOrDefault <SocketHandle>();
     ConstructionGrade[] components = rootObj.GetComponents <ConstructionGrade>();
     this.grades = new ConstructionGrade[5];
     ConstructionGrade[] constructionGradeArray = components;
     for (int i = 0; i < (int)constructionGradeArray.Length; i++)
     {
         ConstructionGrade constructionGrade = constructionGradeArray[i];
         constructionGrade.construction = this;
         this.grades[(int)constructionGrade.gradeBase.type] = constructionGrade;
     }
     for (int j = 0; j < (int)this.grades.Length; j++)
     {
         if (this.grades[j] != null)
         {
             this.defaultGrade = this.grades[j];
             return;
         }
     }
 }
예제 #6
0
 public bool CheckPlacement(Deployable deployable, Ray ray, float fDistance)
 {
     using (TimeWarning.New("Deploy.CheckPlacement", 0.1f))
     {
         RaycastHit raycastHit;
         if (!Physics.Raycast(ray, ref raycastHit, fDistance, 1235288065))
         {
             return(false);
         }
         DeployVolume[] all              = PrefabAttribute.server.FindAll <DeployVolume>(deployable.prefabID);
         Vector3        point            = ((RaycastHit) ref raycastHit).get_point();
         Quaternion     deployedRotation = this.GetDeployedRotation(((RaycastHit) ref raycastHit).get_normal(), ((Ray) ref ray).get_direction());
         Quaternion     rotation         = deployedRotation;
         DeployVolume[] volumes          = all;
         if (DeployVolume.Check(point, rotation, volumes, -1))
         {
             return(false);
         }
         if (!this.IsPlacementAngleAcceptable(((RaycastHit) ref raycastHit).get_point(), deployedRotation))
         {
             return(false);
         }
     }
     return(true);
 }
예제 #7
0
 protected override void AttributeSetup(
     GameObject rootObj,
     string name,
     bool serverside,
     bool clientside,
     bool bundling)
 {
     base.AttributeSetup(rootObj, name, serverside, clientside, bundling);
     this.isBuildingPrivilege = Object.op_Implicit((Object)rootObj.GetComponent <BuildingPrivlidge>());
     this.bounds         = ((BaseEntity)rootObj.GetComponent <BaseEntity>()).bounds;
     this.deployable     = (Deployable)((Component)this).GetComponent <Deployable>();
     this.placeholder    = (ConstructionPlaceholder)((Component)this).GetComponentInChildren <ConstructionPlaceholder>();
     this.allSockets     = (Socket_Base[])((Component)this).GetComponentsInChildren <Socket_Base>(true);
     this.allProximities = (BuildingProximity[])((Component)this).GetComponentsInChildren <BuildingProximity>(true);
     this.socketHandle   = ((IEnumerable <SocketHandle>)((Component)this).GetComponentsInChildren <SocketHandle>(true)).FirstOrDefault <SocketHandle>();
     M0[] components = rootObj.GetComponents <ConstructionGrade>();
     this.grades = new ConstructionGrade[5];
     foreach (ConstructionGrade constructionGrade in (ConstructionGrade[])components)
     {
         constructionGrade.construction = this;
         this.grades[(int)constructionGrade.gradeBase.type] = constructionGrade;
     }
     for (int index = 0; index < this.grades.Length; ++index)
     {
         if (!((PrefabAttribute)this.grades[index] == (PrefabAttribute)null))
         {
             this.defaultGrade = this.grades[index];
             break;
         }
     }
 }
예제 #8
0
        public override void OnEnter()
        {
            base.OnEnter();

            if (NetworkServer.active)
            {
                List <DeployableInfo> list = base.characterBody?.master?.deployablesList;
                foreach (DeployableInfo v in list)
                {
                    if (v.slot == DecoyModule.deployableSlot)
                    {
                        Deployable dep = v.deployable;
                        if (dep == null)
                        {
                            continue;
                        }
                        GameObject obj = dep.gameObject;
                        if (obj == null)
                        {
                            continue;
                        }
                        CharacterMaster master = obj.GetComponent <CharacterMaster>();
                        if (master)
                        {
                            master.TrueKill();
                        }
                    }
                }
            }

            if (base.isAuthority)
            {
                base.outer.SetNextStateToMain();
            }
        }
예제 #9
0
 public static void Postfix(Deployable __instance)
 {
     if (__instance.IsDeployed && !__instance.PackedStateItemPrefab)
     {
         Instance.AddDestroyInteraction(__instance);
     }
 }
예제 #10
0
        private void AddDestroyInteraction(Deployable deployable)
        {
            if (!deployable.PackedStateItemPrefab)
            {
                var item = deployable.m_item ?? deployable.GetComponent <Item>();
                if (item.InteractionHolder && item.InteractionHolder.GetComponent <InteractionDestroy>())
                {
                    return;
                }

                var holder = item.InteractionHolder;

                // add custom "Destroy" component
                var comp = holder.AddComponent <InteractionDestroy>();

                // set up the activator and base for our hold action, and do what the game normally does for the disassemble interaction
                var activator = holder.GetComponent <InteractionActivator>();
                activator.AddHoldInteractionOverride(comp);

                var triggerbase = holder.GetComponent <InteractionTriggerBase>();
                deployable.m_disassembleInteractionTrigger = triggerbase;

                deployable.RefreshDisassembleCollider();
            }
        }
예제 #11
0
 // Token: 0x06002C9C RID: 11420 RVA: 0x000BC304 File Offset: 0x000BA504
 private void SummonMinion()
 {
     if (!base.characterBody || !base.characterBody.master)
     {
         return;
     }
     if (base.characterBody.master.GetDeployableCount(DeployableSlot.RoboBallMini) < base.characterBody.master.GetDeployableSameSlotLimit(DeployableSlot.RoboBallMini))
     {
         Util.PlaySound(DeployMinions.summonSoundString, base.gameObject);
         if (!NetworkServer.active)
         {
             return;
         }
         Vector3 position = base.FindModelChild(DeployMinions.summonMuzzleString).position;
         DirectorSpawnRequest directorSpawnRequest = new DirectorSpawnRequest((SpawnCard)Resources.Load(string.Format("SpawnCards/CharacterSpawnCards/{0}", DeployMinions.spawnCard)), new DirectorPlacementRule
         {
             placementMode = DirectorPlacementRule.PlacementMode.Direct,
             minDistance   = 0f,
             maxDistance   = 0f,
             position      = position
         }, RoR2Application.rng);
         directorSpawnRequest.summonerBodyObject = base.gameObject;
         GameObject gameObject = DirectorCore.instance.TrySpawnObject(directorSpawnRequest);
         if (gameObject)
         {
             CharacterMaster component = gameObject.GetComponent <CharacterMaster>();
             gameObject.GetComponent <Inventory>().SetEquipmentIndex(base.characterBody.inventory.currentEquipmentIndex);
             Deployable deployable = gameObject.AddComponent <Deployable>();
             deployable.onUndeploy = new UnityEvent();
             deployable.onUndeploy.AddListener(new UnityAction(component.TrueKill));
             base.characterBody.master.AddDeployable(deployable, DeployableSlot.RoboBallMini);
         }
     }
 }
예제 #12
0
 public static bool DeployableCast(Deployable __instance)
 {
     try
     {
         //WorkInProgress.Instance.MyLogger.LogDebug($"preDeployableCast[{__instance.name}]");
         if ((__instance.Item.ItemID == (int)eItemIDs.BedrollKit ||
              __instance.Item.ItemID == (int)eItemIDs.TentKit) &&
             __instance.DeployedStateItemPrefab)
         {
             WorkInProgress.Instance.MyLogger.LogDebug($"Set deployed {__instance.name} CustomDurable to {__instance.Item.CurrentDurability}");
             __instance.DeployedStateItemPrefab.gameObject.GetOrAddComponent <CustomDurable>().CurrentDurability = __instance.Item.CurrentDurability;
         }
         else if ((__instance.Item.ItemID == (int)eItemIDs.Bedroll ||
                   __instance.Item.ItemID == (int)eItemIDs.Tent) &&
                  __instance.PackedStateItemPrefab)
         {
             var curDs = __instance.Item.GetComponent <CustomDurable>();
             WorkInProgress.Instance.MyLogger.LogDebug($"Set Packed {__instance.name} CustomDurable to {curDs.CurrentDurability}");
             __instance.PackedStateItemPrefab.gameObject.GetOrAddComponent <CustomDurable>().CurrentDurability = curDs.CurrentDurability;
         }
     }
     catch (Exception ex)
     {
         WorkInProgress.Instance.MyLogger.LogError("DeployableCast: " + ex.Message);
     }
     return(true);
 }
예제 #13
0
    public void CreateObstacle()
    {
        GridCell   deployCell = Grid.Instance.GetCell(cellIdToPosition);
        Transform  tr         = PhotonNetwork.Instantiate(ObstacleCodeCall, deployCell.transform.position, Quaternion.identity, 0).transform;
        Deployable towerComp  = tr.GetComponent <Deployable>();

        towerComp.InitialDeploy(deployCell.CellId);
    }
예제 #14
0
    public LocalDamagable(Deployable soldier, SoldierHPBar soldierHp)
    {
        this.deployable = soldier;
        this.soldierHp  = soldierHp;
        this.soldierHp.Init(this);

        frameHp = soldierHp.MaxHp;
    }
예제 #15
0
            public static void Postfix(Deployable __instance)
            {
                var self = __instance;

                if (self.IsDeployed && self.PackedStateItemPrefab == null)
                {
                    Instance.AddDestroyInteraction(self);
                }
            }
예제 #16
0
    public void DoDeploy_Regular(Deployable deployable, Ray ray)
    {
        if (!HasItemAmount())
        {
            return;
        }
        BasePlayer ownerPlayer = GetOwnerPlayer();

        if (!ownerPlayer)
        {
            return;
        }
        if (!ownerPlayer.CanBuild())
        {
            ownerPlayer.ChatMessage("Building is blocked at player position!");
        }
        else if (ConVar.AntiHack.objectplacement && ownerPlayer.TriggeredAntiHack())
        {
            ownerPlayer.ChatMessage("AntiHack!");
        }
        else
        {
            RaycastHit hitInfo;
            if (!CheckPlacement(deployable, ray, 8f) || !UnityEngine.Physics.Raycast(ray, out hitInfo, 8f, 1235288065))
            {
                return;
            }
            Vector3           point            = hitInfo.point;
            Quaternion        deployedRotation = GetDeployedRotation(hitInfo.normal, ray.direction);
            Item              ownerItem        = GetOwnerItem();
            ItemModDeployable modDeployable    = GetModDeployable();
            if (ownerPlayer.Distance(point) > 3f)
            {
                ownerPlayer.ChatMessage("Too far away!");
                return;
            }
            if (!ownerPlayer.CanBuild(point, deployedRotation, deployable.bounds))
            {
                ownerPlayer.ChatMessage("Building is blocked at placement position!");
                return;
            }
            BaseEntity baseEntity = GameManager.server.CreateEntity(modDeployable.entityPrefab.resourcePath, point, deployedRotation);
            if (!baseEntity)
            {
                Debug.LogWarning("Couldn't create prefab:" + modDeployable.entityPrefab.resourcePath);
                return;
            }
            baseEntity.skinID = ownerItem.skin;
            baseEntity.SendMessage("SetDeployedBy", ownerPlayer, SendMessageOptions.DontRequireReceiver);
            baseEntity.OwnerID = ownerPlayer.userID;
            baseEntity.Spawn();
            modDeployable.OnDeployed(baseEntity, ownerPlayer);
            Interface.CallHook("OnItemDeployed", this, modDeployable, baseEntity);
            UseItemAmount(1);
        }
    }
예제 #17
0
    public void DoDeploy_Slot(Deployable deployable, Ray ray, uint entityID)
    {
        if (!base.HasItemAmount())
        {
            return;
        }
        BasePlayer ownerPlayer = base.GetOwnerPlayer();

        if (!ownerPlayer)
        {
            return;
        }
        if (!ownerPlayer.CanBuild())
        {
            return;
        }
        BaseEntity baseEntity = BaseNetworkable.serverEntities.Find(entityID) as BaseEntity;

        if (baseEntity == null)
        {
            return;
        }
        if (!baseEntity.HasSlot(deployable.slot))
        {
            return;
        }
        if (baseEntity.GetSlot(deployable.slot) != null)
        {
            return;
        }
        Item ownerItem = base.GetOwnerItem();
        ItemModDeployable modDeployable = this.GetModDeployable();
        GameManager       gameManager   = GameManager.server;
        string            str           = modDeployable.entityPrefab.resourcePath;
        Vector3           vector3       = new Vector3();
        Quaternion        quaternion    = new Quaternion();
        BaseEntity        baseEntity1   = gameManager.CreateEntity(str, vector3, quaternion, true);

        if (baseEntity1 != null)
        {
            baseEntity1.skinID = ownerItem.skin;
            baseEntity1.SetParent(baseEntity, baseEntity.GetSlotAnchorName(deployable.slot), false, false);
            baseEntity1.OwnerID = ownerPlayer.userID;
            baseEntity1.OnDeployed(baseEntity);
            baseEntity1.Spawn();
            baseEntity.SetSlot(deployable.slot, baseEntity1);
            if (deployable.placeEffect.isValid)
            {
                Effect.server.Run(deployable.placeEffect.resourcePath, baseEntity.transform.position, Vector3.up, null, false);
            }
        }
        modDeployable.OnDeployed(baseEntity1, ownerPlayer);
        Interface.CallHook("OnItemDeployed", this, baseEntity);
        base.UseItemAmount(1);
    }
예제 #18
0
        public static void Prefix(Deployable __instance)
        {
            var item = At.GetField(__instance as ItemExtension, "m_item") as Item;

            if (!item)
            {
                item = __instance.GetComponent <Item>();
            }

            At.SetField(__instance as ItemExtension, "m_item", item);
        }
        public void RemoveComponent(Deployable deployable)
        {
            var v3        = new SerializedVector3(deployable.transform.position - Origo.Position.ToVector3());
            var q         = new SerializedQuaternion(deployable.transform.rotation);
            var component = new DeployableComponent(deployable, v3, q);

            if (DeployableComponents.ContainsKey(component.ToString()))
            {
                DeployableComponents.Remove(component.ToString());
            }
        }
예제 #20
0
    public void DoDeploy_Slot(Deployable deployable, Ray ray, uint entityID)
    {
        if (!HasItemAmount())
        {
            return;
        }
        BasePlayer ownerPlayer = GetOwnerPlayer();

        if (!ownerPlayer)
        {
            return;
        }
        if (!ownerPlayer.CanBuild())
        {
            ownerPlayer.ChatMessage("Building is blocked at player position!");
            return;
        }
        BaseEntity baseEntity = BaseNetworkable.serverEntities.Find(entityID) as BaseEntity;

        if (baseEntity == null || !baseEntity.HasSlot(deployable.slot) || baseEntity.GetSlot(deployable.slot) != null)
        {
            return;
        }
        if (ownerPlayer.Distance(baseEntity) > 3f)
        {
            ownerPlayer.ChatMessage("Too far away!");
            return;
        }
        if (!ownerPlayer.CanBuild(baseEntity.WorldSpaceBounds()))
        {
            ownerPlayer.ChatMessage("Building is blocked at placement position!");
            return;
        }
        Item ownerItem = GetOwnerItem();
        ItemModDeployable modDeployable = GetModDeployable();
        BaseEntity        baseEntity2   = GameManager.server.CreateEntity(modDeployable.entityPrefab.resourcePath);

        if (baseEntity2 != null)
        {
            baseEntity2.skinID = ownerItem.skin;
            baseEntity2.SetParent(baseEntity, baseEntity.GetSlotAnchorName(deployable.slot));
            baseEntity2.OwnerID = ownerPlayer.userID;
            baseEntity2.OnDeployed(baseEntity, ownerPlayer);
            baseEntity2.Spawn();
            baseEntity.SetSlot(deployable.slot, baseEntity2);
            if (deployable.placeEffect.isValid)
            {
                Effect.server.Run(deployable.placeEffect.resourcePath, baseEntity.transform.position, Vector3.up);
            }
        }
        modDeployable.OnDeployed(baseEntity2, ownerPlayer);
        Interface.CallHook("OnItemDeployed", this, baseEntity, baseEntity2);
        UseItemAmount(1);
    }
예제 #21
0
 bool shouldRemove(Deployable deployable, bool forceRemove, float eraseRadius = 3f)
 {
     if (forceRemove)
     {
         return(true);
     }
     foreach (Collider collider in UnityEngine.Physics.OverlapSphere(deployable.transform.position, eraseRadius, constructionColl))
     {
         return(false);
     }
     return(true);
 }
예제 #22
0
 public static void OnItemUse(Deployable __instance)
 {
     try
     {
         WorkInProgress.Instance.MyLogger.LogDebug($"{__instance.name}'s Durability--");
         __instance.Item.ReduceDurability(1);
         //WorkInProgress.Instance.MyLogger.LogDebug($"Deployable_OnItemUse[{__instance.Item.Name}]=C" + __instance.Item.CurrentDurability + "/S" + __instance.Item.StartingDurability + "/M" + s.MaxDurability);
     }
     catch (Exception ex)
     {
         WorkInProgress.Instance.MyLogger.LogError(ex.Message);
     }
 }
        static void RecordAllConnected(Structure structure, BuildingPart bp)
        {
            var partList   = new List <object>();
            var posList    = new List <Vector3>();
            int layerMasks = LayerMask.GetMask("Construction", "Construction Trigger", "Deployed");

            partList.Add(bp.buildingBlock);
            posList.Add(bp.Location);
            structure.AddComponent(bp);
            for (int i = 0; i < posList.Count; i++)
            {
                Collider[] colliders = Physics.OverlapSphere(posList[i], 3f, layerMasks);
                foreach (Collider collider in colliders)
                {
                    if (collider.isTrigger)
                    {
                        continue;
                    }
                    if (collider.GetComponentInParent <BuildingBlock>() != null)
                    {
                        BuildingBlock buildingBlock = collider.GetComponentInParent <BuildingBlock>();
                        if (!partList.Contains(buildingBlock))
                        {
                            partList.Add(buildingBlock);
                            posList.Add(buildingBlock.transform.position);
                            structure.AddComponent(new BuildingPart(buildingBlock));
                        }
                    }
                    else if (collider.GetComponentInParent <Deployable>() != null)
                    {
                        Deployable deployable = collider.GetComponentInParent <Deployable>();
                        if (!partList.Contains(deployable))
                        {
                            partList.Add(deployable);
                            posList.Add(deployable.transform.position);
                            structure.AddComponent(deployable);
                        }
                    }
                    else if (collider.GetComponentInParent <Spawnable>() != null)
                    {
                        Spawnable spawnable = collider.GetComponentInParent <Spawnable>();
                        if (!partList.Contains(spawnable))
                        {
                            partList.Add(spawnable);
                            posList.Add(spawnable.transform.position);
                            structure.AddComponent(spawnable);
                        }
                    }
                }
            }
        }
예제 #24
0
    public void DoDeploy_Regular(Deployable deployable, Ray ray)
    {
        RaycastHit raycastHit;

        if (!base.HasItemAmount())
        {
            return;
        }
        BasePlayer ownerPlayer = base.GetOwnerPlayer();

        if (!ownerPlayer)
        {
            return;
        }
        if (!ownerPlayer.CanBuild())
        {
            ownerPlayer.ChatMessage("Building is blocked!");
            return;
        }
        if (ConVar.AntiHack.objectplacement && ownerPlayer.TriggeredAntiHack(1f, Single.PositiveInfinity))
        {
            ownerPlayer.ChatMessage("AntiHack!");
            return;
        }
        if (!this.CheckPlacement(deployable, ray, 8f))
        {
            return;
        }
        if (!UnityEngine.Physics.Raycast(ray, out raycastHit, 8f, 1235288065))
        {
            return;
        }
        Quaternion        deployedRotation = this.GetDeployedRotation(raycastHit.normal, ray.direction);
        Item              ownerItem        = base.GetOwnerItem();
        ItemModDeployable modDeployable    = this.GetModDeployable();
        BaseEntity        baseEntity       = GameManager.server.CreateEntity(modDeployable.entityPrefab.resourcePath, raycastHit.point, deployedRotation, true);

        if (!baseEntity)
        {
            Debug.LogWarning(string.Concat("Couldn't create prefab:", modDeployable.entityPrefab.resourcePath));
            return;
        }
        baseEntity.skinID = ownerItem.skin;
        baseEntity.SendMessage("SetDeployedBy", ownerPlayer, SendMessageOptions.DontRequireReceiver);
        baseEntity.OwnerID = ownerPlayer.userID;
        baseEntity.Spawn();
        modDeployable.OnDeployed(baseEntity, ownerPlayer);
        Interface.CallHook("OnItemDeployed", this, baseEntity);
        base.UseItemAmount(1);
    }
예제 #25
0
    public void RPC_Rotate(BaseEntity.RPCMessage msg)
    {
        BasePlayer basePlayer = msg.player;

        if (basePlayer.CanBuild() && basePlayer.GetHeldEntity() && basePlayer.GetHeldEntity().GetComponent <Hammer>() != null)
        {
            base.transform.rotation = Quaternion.LookRotation(-base.transform.forward, base.transform.up);
            base.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
            Deployable component = base.GetComponent <Deployable>();
            if (component != null)
            {
                Effect.server.Run(component.placeEffect.resourcePath, base.transform.position, Vector3.up, null, false);
            }
        }
    }
예제 #26
0
 public static void CancelDeploy(DeployablePlacer __instance)
 {
     try
     {
         Deployable m_deployedItem = (Deployable)AccessTools.Field(typeof(DeployablePlacer), "m_deployedItem").GetValue(__instance);
         if (Enum.IsDefined(typeof(eItemIDs), m_deployedItem.Item.ItemID))
         {
             WorkInProgress.Instance.MyLogger.LogDebug($"Cancel deployment of {m_deployedItem.Item.name} > Durability++");
             m_deployedItem.Item.ReduceDurability(-1);
         }
     }
     catch (Exception ex)
     {
         WorkInProgress.Instance.MyLogger.LogError("CancelDeploy: " + ex.Message);
     }
 }
예제 #27
0
    public void DoDeploy_Regular(Deployable deployable, Ray ray)
    {
        if (!this.HasItemAmount())
        {
            return;
        }
        BasePlayer ownerPlayer = this.GetOwnerPlayer();

        if (!Object.op_Implicit((Object)ownerPlayer))
        {
            return;
        }
        if (!ownerPlayer.CanBuild())
        {
            ownerPlayer.ChatMessage("Building is blocked!");
        }
        else if (ConVar.AntiHack.objectplacement && ownerPlayer.TriggeredAntiHack(1f, float.PositiveInfinity))
        {
            ownerPlayer.ChatMessage("AntiHack!");
        }
        else
        {
            RaycastHit raycastHit;
            if (!this.CheckPlacement(deployable, ray, 8f) || !Physics.Raycast(ray, ref raycastHit, 8f, 1235288065))
            {
                return;
            }
            Quaternion        deployedRotation = this.GetDeployedRotation(((RaycastHit) ref raycastHit).get_normal(), ((Ray) ref ray).get_direction());
            Item              ownerItem        = this.GetOwnerItem();
            ItemModDeployable modDeployable    = this.GetModDeployable();
            BaseEntity        entity           = GameManager.server.CreateEntity(modDeployable.entityPrefab.resourcePath, ((RaycastHit) ref raycastHit).get_point(), deployedRotation, true);
            if (!Object.op_Implicit((Object)entity))
            {
                Debug.LogWarning((object)("Couldn't create prefab:" + modDeployable.entityPrefab.resourcePath));
            }
            else
            {
                entity.skinID = ownerItem.skin;
                ((Component)entity).SendMessage("SetDeployedBy", (object)ownerPlayer, (SendMessageOptions)1);
                entity.OwnerID = ownerPlayer.userID;
                entity.Spawn();
                modDeployable.OnDeployed(entity, ownerPlayer);
                Interface.CallHook("OnItemDeployed", (object)this, (object)entity);
                this.UseItemAmount(1);
            }
        }
    }
예제 #28
0
 //Method to give turrets the starting bonus of its owner
 private void CharacterMaster_AddDeployable(On.RoR2.CharacterMaster.orig_AddDeployable orig,
                                            CharacterMaster self,
                                            Deployable deployable,
                                            DeployableSlot slot)
 {
     orig(self, deployable, slot);
     if (TurretReceivesBonusFromEngineer.Value &&
         slot == DeployableSlot.EngiTurret)
     {
         var ownerMasterBonus = deployable.ownerMaster.inventory.infusionBonus;
         if (ownerMasterBonus > 0)
         {
             var turretMaster = deployable.GetComponent <CharacterMaster>();
             turretMaster.inventory.AddInfusionBonus(ownerMasterBonus);
         }
     }
 }
 public void OnReceived()
 {
     if (_body && _body.master)
     {
         var dispMaster = new MasterSummon {
             masterPrefab          = MasterCatalog.GetMasterPrefab(_masterIndex),
             position              = _pos,
             rotation              = _rot,
             summonerBodyObject    = _body.gameObject,
             ignoreTeamMemberLimit = true,
             inventoryToCopy       = _body.inventory
         }.Perform();
         Deployable deployable = dispMaster.gameObject.AddComponent <Deployable>();
         deployable.onUndeploy = new UnityEvent();
         deployable.onUndeploy.AddListener(new UnityAction(dispMaster.TrueKill));
         _body.master.AddDeployable(deployable, EngiUtilitySpeedispenser.instance.deployableSlot);
     }
 }
예제 #30
0
    public void RPC_Rotate(BaseEntity.RPCMessage msg)
    {
        BasePlayer player = msg.player;

        if (!player.CanBuild() || !Object.op_Implicit((Object)player.GetHeldEntity()) || !Object.op_Inequality((Object)((Component)player.GetHeldEntity()).GetComponent <Hammer>(), (Object)null))
        {
            return;
        }
        ((Component)this).get_transform().set_rotation(Quaternion.LookRotation(Vector3.op_UnaryNegation(((Component)this).get_transform().get_forward()), ((Component)this).get_transform().get_up()));
        this.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
        Deployable component = (Deployable)((Component)this).GetComponent <Deployable>();

        if (!((PrefabAttribute)component != (PrefabAttribute)null))
        {
            return;
        }
        Effect.server.Run(component.placeEffect.resourcePath, ((Component)this).get_transform().get_position(), Vector3.get_up(), (Connection)null, false);
    }
 public void AddComponent(Deployable deployable)
 {
     if (Origo == null)
     {
         Origo = new Origo(new SerializedVector3(deployable.transform.position), new SerializedQuaternion(deployable.transform.rotation));
     }
     var v3 = new SerializedVector3(deployable.transform.position - Origo.Position.ToVector3());
     var q = new SerializedQuaternion(deployable.transform.rotation);
     var component = new DeployableComponent(deployable, v3, q);
     if (component == null)
     {
         Pluton.Logger.LogDebug("[StructureRecorder] Deployable component is null!");
         return;
     }
     if (!DeployableComponents.ContainsKey(component.ToString()))
     {
         DeployableComponents.Add(component.ToString(), component);
     }
     else
     {
         DeployableComponents[component.ToString()] = component;
     }
 }
예제 #32
0
        bool GetDeployableClean(BuildingBlock initialBlock, float playerRot, Deployable currentBlock, out Dictionary<string, object> data)
        {
            data = new Dictionary<string, object>();
            posCleanData = new Dictionary<string, object>();
            rotCleanData = new Dictionary<string, object>();

            normedPos = GenerateGoodPos(initialBlock.transform.position, currentBlock.transform.position, playerRot);
            normedYRot = currentBlock.transform.rotation.ToEulerAngles().y - playerRot;
            data.Add("prefabname", StringPool.Get(currentBlock.prefabID).ToString());

            posCleanData.Add("x", normedPos.x);
            posCleanData.Add("y", normedPos.y);
            posCleanData.Add("z", normedPos.z);
            data.Add("pos", posCleanData);

            rotCleanData.Add("x", currentBlock.transform.rotation.ToEulerAngles().x);
            rotCleanData.Add("y", normedYRot);
            rotCleanData.Add("z", currentBlock.transform.rotation.ToEulerAngles().z);
            data.Add("rot", rotCleanData);
            return true;
        }
예제 #33
0
 bool shouldRemove(Deployable deployable, bool forceRemove, float eraseRadius = 0.5f )
 {
     if (forceRemove) return true;
     foreach( Collider collider in UnityEngine.Physics.OverlapSphere(deployable.transform.position, eraseRadius, constructionColl) )
     {
         return false;
     }
     return true;
 }
 public void RemoveComponent(Deployable deployable)
 {
     var v3 = new SerializedVector3(deployable.transform.position - Origo.Position.ToVector3());
     var q = new SerializedQuaternion(deployable.transform.rotation);
     var component = new DeployableComponent(deployable, v3, q);
     if (DeployableComponents.ContainsKey(component.ToString()))
     {
         DeployableComponents.Remove(component.ToString());
     }
 }