Exemplo n.º 1
0
 public static void deployableKO(DeployableObject dep, DamageEvent e)
 {
     try
     {
         InstaKOCommand command = ChatCommand.GetCommand("instako") as InstaKOCommand;
         if (command.IsOn(e.attacker.client.userID))
         {
             try
             {
                 Helper.Log("StructDestroyed.txt", string.Concat(new object[] { e.attacker.client.netUser.displayName, " [", e.attacker.client.netUser.userID, "] destroyed (InstaKO) ", NetUser.FindByUserID(dep.ownerID).displayName, "'s ", dep.gameObject.name.Replace("(Clone)", "") }));
             }
             catch
             {
                 if (Core.userCache.ContainsKey(dep.ownerID))
                 {
                     Helper.Log("StructDestroyed.txt", string.Concat(new object[] { e.attacker.client.netUser.displayName, " [", e.attacker.client.netUser.userID, "] destroyed (InstaKO) ", Core.userCache[dep.ownerID], "'s ", dep.gameObject.name.Replace("(Clone)", "") }));
                 }
             }
             dep.OnKilled();
         }
         else
         {
             dep.UpdateClientHealth();
         }
     }
     catch
     {
         dep.UpdateClientHealth();
     }
 }
Exemplo n.º 2
0
        public static GameObject Spawn(string prefab, Vector3 position, Quaternion rotation, int count)
        {
            GameObject gameObject = null;

            for (int i = 0; i < count; i++)
            {
                if (prefab == ":player_soldier")
                {
                    gameObject = NetCull.InstantiateDynamic(uLink.NetworkPlayer.server, prefab, position, rotation);
                }
                else if (prefab.Contains("C130"))
                {
                    gameObject = NetCull.InstantiateClassic(prefab, position, rotation, 0);
                }
                else
                {
                    gameObject = NetCull.InstantiateStatic(prefab, position, rotation);
                    gameObject.GetComponent <StructureComponent>();
                    DeployableObject component = gameObject.GetComponent <DeployableObject>();
                    if (component != null)
                    {
                        component.ownerID   = 0uL;
                        component.creatorID = 0uL;
                        component.CacheCreator();
                        component.CreatorSet();
                    }
                }
            }
            return(gameObject);
        }
Exemplo n.º 3
0
        public static bool checkOwner(DeployableObject obj, Controllable controllable)
        {
            bool flag;

            Fougerite.Player pl = Fougerite.Server.Cache[controllable.playerClient.userID];
            if (obj.ownerID == pl.UID)
            {
                flag = true;
            }
            else if (obj is SleepingBag)
            {
                flag = false;
            }
            else
            {
                ShareCommand command = ChatCommand.GetCommand("share") as ShareCommand;
                ArrayList    list    = (ArrayList)command.GetSharedDoors()[obj.ownerID];
                if (list == null)
                {
                    flag = false;
                }
                if (list.Contains(pl.UID))
                {
                    flag = true;
                }
                flag = false;
            }
            return(flag);
        }
Exemplo n.º 4
0
 public static void deployableKO(DeployableObject dep, DamageEvent e)
 {
     try
     {
         InstaKOCommand command = ChatCommand.GetCommand("instako") as InstaKOCommand;
         if (command.IsOn(e.attacker.client.userID))
         {
             try
             {
                 Helper.Log("StructDestroyed.txt", string.Concat(new object[] { e.attacker.client.netUser.displayName, " [", e.attacker.client.netUser.userID, "] destroyed (InstaKO) ", NetUser.FindByUserID(dep.ownerID).displayName, "'s ", dep.gameObject.name.Replace("(Clone)", "") }));
             }
             catch
             {
                 if (Core.userCache.ContainsKey(dep.ownerID))
                 {
                     Helper.Log("StructDestroyed.txt", string.Concat(new object[] { e.attacker.client.netUser.displayName, " [", e.attacker.client.netUser.userID, "] destroyed (InstaKO) ", Core.userCache[dep.ownerID], "'s ", dep.gameObject.name.Replace("(Clone)", "") }));
                 }
             }
             dep.OnKilled();
         }
         else
         {
             dep.UpdateClientHealth();
         }
     }
     catch
     {
         dep.UpdateClientHealth();
     }
 }
Exemplo n.º 5
0
 void TryToRemove(TakeDamage takedamage, RemoveHandler rplayer)
 {
     cachedStructure  = takedamage.GetComponent <StructureComponent>();
     cachedDeployable = takedamage.GetComponent <DeployableObject>();
     if (cachedStructure != null && cachedStructure._master != null)
     {
         cachedMaster = cachedStructure._master;
         if (!canRemove(rplayer, cachedMaster.ownerID.ToString()))
         {
             SendReply(rplayer.playerclient.netUser, noRemoveAccess); return;
         }
         if (rplayer.removeType == "all")
         {
             RemoveAll(cachedMaster, rplayer);
         }
         else
         {
             SimpleRemove(cachedStructure, rplayer);
         }
     }
     else if (cachedDeployable != null)
     {
         if (!canRemove(rplayer, cachedDeployable.ownerID.ToString()))
         {
             SendReply(rplayer.playerclient.netUser, noRemoveAccess); return;
         }
         DeployableRemove(cachedDeployable, rplayer);
     }
 }
Exemplo n.º 6
0
 void cmdChatProd(NetUser netuser, string command, string[] args)
 {
     if (!hasAccess(netuser)) { SendReply(netuser, "You don't have access to this command"); return; }
     cachedCharacter = netuser.playerClient.rootControllable.idMain.GetComponent<Character>();
     if (!MeshBatchPhysics.Raycast(cachedCharacter.eyesRay, out cachedRaycast, out cachedBoolean, out cachedhitInstance)) { SendReply(netuser, "Are you looking at the sky?"); return; }
     if (cachedhitInstance != null)
     {
         cachedCollider = cachedhitInstance.physicalColliderReferenceOnly;
         if (cachedCollider == null) { SendReply(netuser, "Can't prod what you are looking at"); return; }
         cachedStructure = cachedCollider.GetComponent<StructureComponent>();
         if (cachedStructure != null && cachedStructure._master != null)
         {
             cachedMaster = cachedStructure._master;
             var name = PlayerDatabase?.Call("GetPlayerData", cachedMaster.ownerID.ToString(), "name");
             SendReply(netuser, string.Format("{0} - {1} - {2}", cachedStructure.gameObject.name, cachedMaster.ownerID.ToString(), name == null ? "UnknownPlayer" : name.ToString()));
             return;
         }
     }
     else
     {
         cachedDeployable = cachedRaycast.collider.GetComponent<DeployableObject>();
         if (cachedDeployable != null)
         {
             var name = PlayerDatabase?.Call("GetPlayerData", cachedDeployable.ownerID.ToString(), "name");
             SendReply(netuser, string.Format("{0} - {1} - {2}", cachedDeployable.gameObject.name, cachedDeployable.ownerID.ToString(), name == null ? cachedDeployable.ownerName.ToString() : name.ToString()));
             return;
         }
     }
     SendReply(netuser, string.Format("Can't prod what you are looking at: {0}",cachedRaycast.collider.gameObject.name));
 }
Exemplo n.º 7
0
 public static bool checkOwner(DeployableObject obj, Controllable controllable)
 {
     bool flag;
     if (obj.ownerID == controllable.playerClient.userID)
     {
         return true;
     }
     try
     {
         SleepingBag bag1 = (SleepingBag)obj;
         flag = false;
     }
     catch
     {
         try
         {
             ShareCommand command = ChatCommand.GetCommand("share") as ShareCommand;
             ArrayList list = (ArrayList)command.GetSharedDoors()[obj.ownerID];
             if (list == null)
             {
                 return false;
             }
             if (list.Contains(controllable.playerClient.userID))
             {
                 return true;
             }
             flag = false;
         }
         catch (Exception)
         {
             flag = false;
         }
     }
     return flag;
 }
Exemplo n.º 8
0
 public Sleeper(DeployableObject obj)
 {
     this._sleeper    = obj;
     this._instanceid = this._sleeper.GetInstanceID();
     this._uid        = this._sleeper.ownerID;
     this._name       = Fougerite.Server.Cache.ContainsKey(UID) ? Fougerite.Server.Cache[UID].Name : this._sleeper.ownerName;
 }
Exemplo n.º 9
0
 void OnItemDeployedByPlayer(DeployableObject component, IDeployableItem item)
 {
     if (!antiSleepingBagHack)
     {
         return;
     }
     if (component.gameObject.name == "SleepingBagA(Clone)" || component.gameObject.name == "SingleBed(Clone)")
     {
         if (!item.character)
         {
             return;
         }
         if (!(MeshBatchPhysics.Linecast(item.character.eyesOrigin, component.transform.position, out cachedRaycast, out cachedBoolean, out cachedhitInstance)))
         {
             return;
         }
         if (cachedhitInstance == null && cachedRaycast.collider.gameObject.name != "MetalDoor(Clone)")
         {
             return;
         }
         if (Vector3.Distance(item.character.eyesOrigin, component.transform.position) > 9f)
         {
             return;
         }
         AntiCheatBroadcastAdmins(string.Format("{0} tried to spawn a {1} @ {2} from {3}", item.character.playerClient.userName, component.gameObject.name.Replace("(Clone)", ""), component.transform.position.ToString(), item.character.eyesOrigin.ToString()));
         AntiCheatBroadcastAdmins(string.Format("{0} was on the way", (cachedhitInstance == null) ? "Metal Door" : cachedhitInstance.physicalColliderReferenceOnly.gameObject.name.Replace("(Clone)", "")));
         Puts(string.Format("{0} tried to spawn a {1} @ {2} from {3} threw {4}", item.character.playerClient.userName, component.gameObject.name.Replace("(Clone)", ""), component.transform.position.ToString(), item.character.eyesOrigin.ToString(), (cachedhitInstance == null) ? "Metal Door" : cachedhitInstance.physicalColliderReferenceOnly.gameObject.name.Replace("(Clone)", "")));
         NetCull.Destroy(component.gameObject);
         if (sleepingbaghackPunish)
         {
             Punish(item.character.playerClient, string.Format("rSleepHack ({0})", (cachedhitInstance == null) ? "Metal Door" : cachedhitInstance.physicalColliderReferenceOnly.gameObject.name.Replace("(Clone)", "")));
         }
     }
 }
Exemplo n.º 10
0
        private object Spawn(string prefab, Vector3 location, Quaternion rotation, int rep)
        {
            prefab = prefab.Trim();
            object obj2 = null;

            try
            {
                for (int i = 0; i < rep; i++)
                {
                    if (prefab == ":player_soldier")
                    {
                        obj2 = NetCull.InstantiateDynamic(uLink.NetworkPlayer.server, prefab, location, rotation);
                    }
                    else if (prefab.Contains("C130"))
                    {
                        obj2 = NetCull.InstantiateClassic(prefab, location, rotation, 0);
                    }
                    else
                    {
                        GameObject obj3 = NetCull.InstantiateStatic(prefab, location, rotation);
                        obj2 = obj3;
                        StructureComponent component = obj3.GetComponent <StructureComponent>();
                        if (component != null)
                        {
                            obj2 = new Entity(component);
                        }
                        else if (obj3.GetComponent <LootableObject>())
                        {
                            obj2 = new Entity(obj3.GetComponent <LootableObject>());
                        }
                        else if (obj3.GetComponent <SupplyCrate>())
                        {
                            obj2 = new Entity(obj3.GetComponent <SupplyCrate>());
                        }
                        else if (obj3.GetComponent <ResourceTarget>())
                        {
                            obj2 = new Entity(obj3.GetComponent <ResourceTarget>());
                        }
                        else
                        {
                            DeployableObject obj4 = obj3.GetComponent <DeployableObject>();
                            if (obj4 != null)
                            {
                                obj4.ownerID   = 0L;
                                obj4.creatorID = 0L;
                                obj4.CacheCreator();
                                obj4.CreatorSet();
                                obj2 = new Entity(obj4);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logger.LogError("Spawn error: " + e.ToString());
            }
            return(obj2);
        }
Exemplo n.º 11
0
        private static bool smethod_0(TruthDetector truthDetector_0, Vector3 vector3_0, ref Vector3 vector3_1)
        {
            RaycastHit        hit;
            bool              flag;
            MeshBatchInstance instance;
            Vector3           vector = vector3_1 - vector3_0;

            if (vector.magnitude == 0f)
            {
                return(false);
            }
            Ray ray = new Ray(vector3_0 + new Vector3(0f, 0.75f, 0f), vector.normalized);

            if (!Facepunch.MeshBatch.MeshBatchPhysics.SphereCast(ray, 0.1f, out hit, vector.magnitude, 0x20180403, out flag, out instance))
            {
                return(false);
            }
            IDMain             main      = flag ? instance.idMain : IDBase.GetMain(hit.collider);
            GameObject         obj2      = (main != null) ? main.gameObject : hit.collider.gameObject;
            string             newValue  = obj2.name.Trim();
            DeployableObject   obj3      = obj2.GetComponent <DeployableObject>();
            StructureComponent component = obj2.GetComponent <StructureComponent>();

            if (newValue == "")
            {
                newValue = "Mesh Texture";
            }
            else if (obj3 != null)
            {
                newValue = Helper.NiceName(obj3.name);
                if (truthDetector_0.netUser.userID == obj3.ownerID)
                {
                    return(false);
                }
                if (Users.SharedGet(obj3.ownerID, truthDetector_0.netUser.userID))
                {
                    return(false);
                }
            }
            else if (component != null)
            {
                newValue = Helper.NiceName(component.name);
                if (truthDetector_0.netUser.userID == component._master.ownerID)
                {
                    return(false);
                }
                if (Users.SharedGet(component._master.ownerID, truthDetector_0.netUser.userID))
                {
                    return(false);
                }
            }
            PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.WallHack", truthDetector_0.netUser, "", 0, new DateTime());
            PunishDetails = PunishDetails.Replace("%OBJECT.NAME%", newValue);
            PunishDetails = PunishDetails.Replace("%OBJECT.POS%", hit.point.AsString());
            HackDetected  = HackMethod.WallHack;
            vector3_1     = MoveBack(truthDetector_0, vector3_0, vector3_1);
            return(true);
        }
Exemplo n.º 12
0
 public static bool DeployableObject_BelongsTo(DeployableObject obj, Controllable controllable)
 {
     object[] args = new object[]
     {
         obj,
         controllable
     };
     return(Method.Invoke("RustExtended.RustHook.DeployableObject_BelongsTo", args).AsBoolean);
 }
Exemplo n.º 13
0
        DeployableObject SpawnDeployable(string prefab, Vector3 pos, Quaternion angles)
        {
            DeployableObject build = NetCull.InstantiateStatic(prefab, pos, angles).GetComponent <DeployableObject>();

            if (build == null)
            {
                return(null);
            }
            return(build);
        }
Exemplo n.º 14
0
 void DeployableRemove(DeployableObject deployable, RemoveHandler rplayer)
 {
     if (!canRemoveDeployable(deployable, rplayer.removeType))
     {
         SendReply(rplayer.playerclient.netUser, noRemoveAccess); return;
     }
     if (canRefund)
     {
         TryRefund(deployableCloneToGood[deployable.gameObject.name], rplayer);
     }
     TakeDamage.KillSelf(deployable.GetComponent <IDMain>());
 }
Exemplo n.º 15
0
 public static bool IsValidLocation(Vector3 location, Vector3 surfaceNormal, UnityEngine.Quaternion rotation, DeployableObject prefab)
 {
     if (prefab.doEdgeCheck)
     {
         return false;
     }
     if (Vector3.Angle(surfaceNormal, Vector3.up) <= prefab.maxSlope)
     {
         return true;
     }
     return false;
 }
Exemplo n.º 16
0
 bool canRemoveDeployable(DeployableObject deployable, string ttype)
 {
     if (ttype == "admin" || ttype == "all")
     {
         return(true);
     }
     if (deployableCloneToGood[deployable.gameObject.name] == null)
     {
         return(false);
     }
     return((bool)deployableList[deployableCloneToGood[deployable.gameObject.name]]);
 }
Exemplo n.º 17
0
        public static bool CheckOwner(DeployableObject obj, Controllable controllable)
        {
            DoorEvent de = new DoorEvent(new Entity(obj));

            if (obj.ownerID == controllable.playerClient.userID)
            {
                de.Open = true;
            }
            if ((obj.GetComponent <BasicDoor>() != null) && (OnDoorUse != null))
            {
                OnDoorUse(Magma.Player.FindByPlayerClient(controllable.playerClient), de);
            }
            return(de.Open);
        }
Exemplo n.º 18
0
    public virtual void RenderDeployPreview(Vector3 point, Quaternion rot, TransCarrier carrier)
    {
        if (this._aimGizmo != null)
        {
            this._aimGizmo.rotation = rot;
            this._aimGizmo.position = point;
        }
        if (this._prefabRenderer == null)
        {
            DeployableObject objectToPlace = this.datablock.ObjectToPlace;
            if (!objectToPlace)
            {
                return;
            }
            this._prefabRenderer = PrefabRenderer.GetOrCreateRender(objectToPlace.gameObject);
        }
        Material material = (T)this.datablock.overrideMat;

        if (!material)
        {
            PrefabRenderer prefabRenderer = this._prefabRenderer;
            Camera         camera         = MountedCamera.main.camera;
            T t = this.datablock;
            prefabRenderer.Render(camera, Matrix4x4.TRS(point, rot, t.ObjectToPlace.transform.localScale), this._aimGizmo.propertyBlock, null);
        }
        else
        {
            PrefabRenderer prefabRenderer1 = this._prefabRenderer;
            Camera         camera1         = MountedCamera.main.camera;
            T t1 = this.datablock;
            prefabRenderer1.RenderOneMaterial(camera1, Matrix4x4.TRS(point, rot, t1.ObjectToPlace.transform.localScale), this._aimGizmo.propertyBlock, material);
        }
        if (this._aimGizmo != null)
        {
            bool flag = false;
            if (carrier)
            {
                Renderer renderer = carrier.renderer;
                if (renderer is MeshRenderer && renderer && renderer.enabled)
                {
                    flag = true;
                    this._aimGizmo.carrierRenderer = (MeshRenderer)renderer;
                }
            }
            if (!flag)
            {
                this._aimGizmo.carrierRenderer = null;
            }
        }
    }
Exemplo n.º 19
0
        public static bool CheckOwner(DeployableObject obj, Controllable controllable)
        {
            DoorEvent doorEvent = new DoorEvent(new Entity(obj));

            if (obj.ownerID == controllable.playerClient.userID)
            {
                doorEvent.Open = true;
            }
            if (obj.GetComponent <BasicDoor>() != null && Hooks.OnDoorUse != null)
            {
                Hooks.OnDoorUse(Player.FindByPlayerClient(controllable.playerClient), doorEvent);
            }
            return(doorEvent.Open);
        }
Exemplo n.º 20
0
        public Sleeper(DeployableObject obj)
        {
            this._sleeper    = obj;
            this._instanceid = this._sleeper.GetInstanceID();
            this._uid        = this._sleeper.ownerID;
            string name = Fougerite.Server.Cache[UID].Name;

            if (name != null)
            {
                this._name = name;
            }
            else
            {
                this._name = this._sleeper.ownerName;
            }
        }
Exemplo n.º 21
0
        public static bool CheckOwner(DeployableObject obj, Controllable controllable)
        {
            DoorEvent de = new DoorEvent(new Entity(obj));

            if (obj.ownerID == controllable.playerClient.userID)
            {
                de.Open = true;
            }

            if (!(obj is SleepingBag) && OnDoorUse != null)
            {
                OnDoorUse(Fougerite.Server.Cache[controllable.playerClient.userID], de);
            }

            return(de.Open);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Spawns a prefab at the given vector, rotation, N times.
        /// IMPORTANT: Returns the prefab as an Entity class.
        /// Entity class only supports specific types, like LootableObject
        /// SupplyCrate, ResourceTarget, DeployableObject, StructureComponent,
        /// StructureMaster.
        /// The other spawn methods are returning the gameobject instead.
        /// </summary>
        /// <param name="prefab"></param>
        /// <param name="location"></param>
        /// <param name="rotation"></param>
        /// <param name="rep"></param>
        /// <returns></returns>
        public Entity SpawnEntity(string prefab, Vector3 location, Quaternion rotation, int rep = 1)
        {
            Entity obj2 = null;

            prefab = prefab.Trim();
            try
            {
                for (int i = 0; i < rep; i++)
                {
                    GameObject         obj3  = NetCull.InstantiateStatic(prefab, location, rotation);
                    StructureComponent build = obj3.GetComponent <StructureComponent>();
                    if (build != null)
                    {
                        obj2 = new Entity(build);
                    }
                    else if (obj3.GetComponent <LootableObject>())
                    {
                        obj2 = new Entity(obj3.GetComponent <LootableObject>());
                    }
                    else if (obj3.GetComponent <SupplyCrate>())
                    {
                        obj2 = new Entity(obj3.GetComponent <SupplyCrate>());
                    }
                    else if (obj3.GetComponent <ResourceTarget>())
                    {
                        obj2 = new Entity(obj3.GetComponent <ResourceTarget>());
                    }
                    else
                    {
                        DeployableObject obj4 = obj3.GetComponent <DeployableObject>();
                        if (obj4 != null)
                        {
                            obj4.ownerID   = 0L;
                            obj4.creatorID = 0L;
                            obj4.CacheCreator();
                            obj4.CreatorSet();
                            obj2 = new Entity(obj4);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logger.LogError("SpawnEntity error: " + e.ToString());
            }
            return(obj2);
        }
Exemplo n.º 23
0
 void OnItemDeployedByPlayer(DeployableObject component, IDeployableItem item)
 {
     if (!antiWoodDoorGlitch)
     {
         return;
     }
     if (component.gameObject.name == "WoodBoxLarge(Clone)")
     {
         foreach (Collider collider in Physics.OverlapSphere(component.transform.position + Vector3Up, 1.2f, doorLayer))
         {
             if (collider.gameObject.name == "MetalDoor(Clone)")
             {
                 if (doorstate.GetValue(collider.GetComponent <BasicDoor>()).ToString() == "Opened" || doorstate.GetValue(collider.GetComponent <BasicDoor>()).ToString() == "Opening")
                 {
                     ConsoleNetworker.SendClientCommand(item.character.playerClient.netPlayer, "chat.add Oxide " + Facepunch.Utility.String.QuoteSafe(string.Format("{0} should be closed before trying to build here", collider.gameObject.name.ToString().Replace("(Clone)", ""))));
                     item.character.GetComponent <Inventory>().AddItemAmount(item.datablock, 1);
                     timer.Once(0.01f, () => NetCull.Destroy(component.gameObject));
                     return;
                 }
             }
         }
         foreach (Collider collider in Physics.OverlapSphere(component.transform.position + Vector3Up, 0.65f, doorLayer))
         {
             if (collider.gameObject.name == "MetalDoor(Clone)")
             {
                 ConsoleNetworker.SendClientCommand(item.character.playerClient.netPlayer, "chat.add Oxide " + Facepunch.Utility.String.QuoteSafe(string.Format("{0} is blocking the way", collider.gameObject.name.ToString().Replace("(Clone)", ""))));
                 item.character.GetComponent <Inventory>().AddItemAmount(item.datablock, 1);
                 timer.Once(0.01f, () => NetCull.Destroy(component.gameObject));
                 return;
             }
         }
     }
     else if (component.gameObject.name == "MetalDoor(Clone)")
     {
         foreach (Collider collider in Physics.OverlapSphere(component.transform.position + Vector3Up, 0.65f))
         {
             if (collider.gameObject.name == "WoodBoxLarge(Clone)")
             {
                 ConsoleNetworker.SendClientCommand(item.character.playerClient.netPlayer, "chat.add Oxide " + Facepunch.Utility.String.QuoteSafe(string.Format("{0} is blocking the way", collider.gameObject.name.ToString().Replace("(Clone)", ""))));
                 item.character.GetComponent <Inventory>().AddItemAmount(item.datablock, 1);
                 timer.Once(0.01f, () => NetCull.Destroy(component.gameObject));
                 return;
             }
         }
     }
 }
Exemplo n.º 24
0
        public static void ceshi(Inventory hook, ref int m)
        {
            DeployableObject component = hook.idMain.GetComponent <DeployableObject>();

            if (component != null)
            {
                UnityEngine.Debug.Log(component.ownerID.ToString());
                UnityEngine.Debug.Log(hook.ToString());
            }
            UnityEngine.Debug.Log(string.Concat(new string[]
            {
                hook.name,
                "    ",
                m.ToString(),
                "     ",
                hook.ToString()
            }));
        }
Exemplo n.º 25
0
    public virtual void RenderDeployPreview(Vector3 point, Quaternion rot, TransCarrier carrier)
    {
        if (this._aimGizmo != null)
        {
            this._aimGizmo.rotation = rot;
            this._aimGizmo.position = point;
        }
        if (this._prefabRenderer == null)
        {
            DeployableObject objectToPlace = base.datablock.ObjectToPlace;
            if (objectToPlace == null)
            {
                return;
            }
            this._prefabRenderer = PrefabRenderer.GetOrCreateRender(objectToPlace.gameObject);
        }
        Material overrideMat = base.datablock.overrideMat;

        if (overrideMat != null)
        {
            this._prefabRenderer.RenderOneMaterial(MountedCamera.main.camera, Matrix4x4.TRS(point, rot, base.datablock.ObjectToPlace.transform.localScale), this._aimGizmo.propertyBlock, overrideMat);
        }
        else
        {
            this._prefabRenderer.Render(MountedCamera.main.camera, Matrix4x4.TRS(point, rot, base.datablock.ObjectToPlace.transform.localScale), this._aimGizmo.propertyBlock, null);
        }
        if (this._aimGizmo != null)
        {
            bool flag = false;
            if (carrier != null)
            {
                Renderer renderer = carrier.renderer;
                if (((renderer is MeshRenderer) && (renderer != null)) && renderer.enabled)
                {
                    flag = true;
                    this._aimGizmo.carrierRenderer = (MeshRenderer)renderer;
                }
            }
            if (!flag)
            {
                this._aimGizmo.carrierRenderer = null;
            }
        }
    }
Exemplo n.º 26
0
 /////////////////////////////////////////
 // OnItemDeployed(Deployer deployer, BaseEntity deployedEntity)
 // Called when an item was deployed
 /////////////////////////////////////////
 void OnItemDeployedByPlayer(DeployableObject deployedEntity, IDeployableItem deployableItem)
 {
     if (deployableItem.controllable == null)
     {
         return;
     }
     if (hasTag(deployableItem.controllable.playerClient, "nodeploy"))
     {
         if (!hasPermission(deployableItem.controllable.playerClient, "candeploy"))
         {
             timer.Once(0.01f, () => DestroyObject(deployedEntity.gameObject));
             SendMessage(deployableItem.controllable.playerClient, "You are not allowed to deploy here");
         }
     }
     else if (deployedEntity.GetComponent <TimedExplosive>())
     {
         timer.Once(4f, () => CheckPositionExplosive(deployedEntity, deployableItem));
     }
 }
Exemplo n.º 27
0
        private object Spawn(string prefab, Vector3 location, Quaternion rotation, int rep)
        {
            Contract.Requires(!string.IsNullOrEmpty(prefab));
            Contract.Requires(rep >= 0);

            object obj2 = null;

            for (int i = 0; i < rep; i++)
            {
                if (prefab == ":player_soldier")
                {
                    obj2 = NetCull.InstantiateDynamic(uLink.NetworkPlayer.server, prefab, location, rotation);
                }
                else if (prefab.Contains("C130"))
                {
                    obj2 = NetCull.InstantiateClassic(prefab, location, rotation, 0);
                }
                else
                {
                    GameObject obj3 = NetCull.InstantiateStatic(prefab, location, rotation);
                    obj2 = obj3;
                    StructureComponent component = obj3.GetComponent <StructureComponent>();
                    if (component != null)
                    {
                        obj2 = new Entity(component);
                    }
                    else
                    {
                        DeployableObject obj4 = obj3.GetComponent <DeployableObject>();
                        if (obj4 != null)
                        {
                            obj4.ownerID   = 0L;
                            obj4.creatorID = 0L;
                            obj4.CacheCreator();
                            obj4.CreatorSet();
                            obj2 = new Entity(obj4);
                        }
                    }
                }
            }
            return(obj2);
        }
Exemplo n.º 28
0
        void CheckPositionExplosive(DeployableObject deployedEntity, IDeployableItem deployableItem)
        {
            var objects = GameObject.FindObjectsOfType(typeof(Zone));

            if (objects != null)
            {
                foreach (Zone zone in objects)
                {
                    if (zone.info.undestr == null)
                    {
                        continue;
                    }
                    if (Vector3.Distance(deployedEntity.transform.position, zone.info.Location.GetPosition()) < (zone.info.Location.GetRadius() + 5f))
                    {
                        deployableItem.character.GetComponent <Inventory>().AddItemAmount(deployableItem.datablock, 1);
                        NetCull.Destroy(deployedEntity.gameObject);
                    }
                }
            }
        }
Exemplo n.º 29
0
        bool GetDeployableClean(StructureComponent initialBlock, float playerRot, DeployableObject 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", GameObjectToPrefab[currentBlock.gameObject.name]);

            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);
        }
Exemplo n.º 30
0
        public static bool CheckOwner(DeployableObject obj, Controllable controllable)
        {
            try
            {
                DoorEvent de = new DoorEvent(new Entity(obj));
                if (obj.ownerID == controllable.playerClient.userID)
                {
                    de.Open = true;
                }

                if (!(obj is SleepingBag) && OnDoorUse != null)
                {
                    OnDoorUse(Fougerite.Player.FindByPlayerClient(controllable.playerClient), de);
                }
                return(de.Open);
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
            return(false);
        }
Exemplo n.º 31
0
        private object Spawn(string prefab, Vector3 location, Quaternion rotation, int rep)
        {
            object result = null;

            for (int i = 0; i < rep; i++)
            {
                if (prefab == ":player_soldier")
                {
                    result = NetCull.InstantiateDynamic(uLink.NetworkPlayer.server, prefab, location, rotation);
                }
                else if (prefab.Contains("C130"))
                {
                    result = NetCull.InstantiateClassic(prefab, location, rotation, 0);
                }
                else
                {
                    GameObject gameObject = NetCull.InstantiateStatic(prefab, location, rotation);
                    result = gameObject;
                    StructureComponent component = gameObject.GetComponent <StructureComponent>();
                    if (component != null)
                    {
                        result = new Entity(component);
                    }
                    else
                    {
                        DeployableObject component2 = gameObject.GetComponent <DeployableObject>();
                        if (component2 != null)
                        {
                            component2.ownerID   = 0uL;
                            component2.creatorID = 0uL;
                            component2.CacheCreator();
                            component2.CreatorSet();
                            result = new Entity(component2);
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 32
0
 void cmdChatProd(NetUser netuser, string command, string[] args)
 {
     if (!hasAccess(netuser))
     {
         SendReply(netuser, "You don't have access to this command"); return;
     }
     cachedCharacter = netuser.playerClient.rootControllable.idMain.GetComponent <Character>();
     if (!MeshBatchPhysics.Raycast(cachedCharacter.eyesRay, out cachedRaycast, out cachedBoolean, out cachedhitInstance))
     {
         SendReply(netuser, "Are you looking at the sky?"); return;
     }
     if (cachedhitInstance != null)
     {
         cachedCollider = cachedhitInstance.physicalColliderReferenceOnly;
         if (cachedCollider == null)
         {
             SendReply(netuser, "Can't prod what you are looking at"); return;
         }
         cachedStructure = cachedCollider.GetComponent <StructureComponent>();
         if (cachedStructure != null && cachedStructure._master != null)
         {
             cachedMaster = cachedStructure._master;
             var name = PlayerDatabase?.Call("GetPlayerData", cachedMaster.ownerID.ToString(), "name");
             SendReply(netuser, string.Format("{0} - {1} - {2}", cachedStructure.gameObject.name, cachedMaster.ownerID.ToString(), name == null ? "UnknownPlayer" : name.ToString()));
             return;
         }
     }
     else
     {
         cachedDeployable = cachedRaycast.collider.GetComponent <DeployableObject>();
         if (cachedDeployable != null)
         {
             var name = PlayerDatabase?.Call("GetPlayerData", cachedDeployable.ownerID.ToString(), "name");
             SendReply(netuser, string.Format("{0} - {1} - {2}", cachedDeployable.gameObject.name, cachedDeployable.ownerID.ToString(), name == null ? cachedDeployable.ownerName.ToString() : name.ToString()));
             return;
         }
     }
     SendReply(netuser, string.Format("Can't prod what you are looking at: {0}", cachedRaycast.collider.gameObject.name));
 }
Exemplo n.º 33
0
        void PasteDeployables(List <object> deployablesData, Vector3 targetPoint, float targetRot, float heightAdjustment, NetUser player)
        {
            Vector3    OriginRotation = new Vector3(0f, targetRot, 0f);
            Quaternion OriginRot      = Quaternion.EulerRotation(OriginRotation);

            foreach (Dictionary <string, object> deployable in deployablesData)
            {
                Dictionary <string, object> structPos = deployable["pos"] as Dictionary <string, object>;
                Dictionary <string, object> structRot = deployable["rot"] as Dictionary <string, object>;
                string prefabname = (string)deployable["prefabname"];

                Quaternion       newAngles = Quaternion.EulerRotation((new Vector3(Convert.ToSingle(structRot["x"]), Convert.ToSingle(structRot["y"]), Convert.ToSingle(structRot["z"]))) + OriginRotation);
                Vector3          TempPos   = OriginRot * (new Vector3(Convert.ToSingle(structPos["x"]), Convert.ToSingle(structPos["y"]), Convert.ToSingle(structPos["z"])));
                Vector3          NewPos    = TempPos + targetPoint;
                DeployableObject block     = SpawnDeployable(prefabname, NewPos, newAngles);
                if (block != null)
                {
                    block.SetupCreator(player.playerClient.controllable);
                    block.GrabCarrier();
                    LootableObject lootobject = block.GetComponent <LootableObject>();
                    if (lootobject == null)
                    {
                        continue;
                    }
                    List <object> itemlist = deployable["items"] as List <object>;
                    if (itemlist == null || itemlist.Count == 0)
                    {
                        continue;
                    }
                    foreach (Dictionary <string, object> item in itemlist)
                    {
                        lootobject._inventory.AddItemAmount(displaynameToDataBlock[item["name"].ToString()], (displaynameToDataBlock[item["name"].ToString()])._splittable? Convert.ToInt32(item["amount"]) : 1);
                    }
                }
            }
        }
Exemplo n.º 34
0
        public static bool checkOwner(DeployableObject obj, Controllable controllable)
        {
            bool flag;

            if (obj.ownerID == controllable.playerClient.userID)
            {
                return(true);
            }
            try
            {
                SleepingBag bag1 = (SleepingBag)obj;
                flag = false;
            }
            catch
            {
                try
                {
                    ShareCommand command = ChatCommand.GetCommand("share") as ShareCommand;
                    ArrayList    list    = (ArrayList)command.GetSharedDoors()[obj.ownerID];
                    if (list == null)
                    {
                        return(false);
                    }
                    if (list.Contains(controllable.playerClient.userID))
                    {
                        return(true);
                    }
                    flag = false;
                }
                catch (Exception)
                {
                    flag = false;
                }
            }
            return(flag);
        }
Exemplo n.º 35
0
        bool GetDeployableClean(StructureComponent initialBlock, float playerRot, DeployableObject 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", GameObjectToPrefab[currentBlock.gameObject.name]);

            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;
        }
Exemplo n.º 36
0
        public static bool CheckOwner(DeployableObject obj, Controllable controllable)
        {
            try
            {
                DoorEvent de = new DoorEvent(new Entity(obj));
                if (obj.ownerID == controllable.playerClient.userID)
                    de.Open = true;

                if (!(obj is SleepingBag) && OnDoorUse != null)
                    OnDoorUse(Fougerite.Player.FindByPlayerClient(controllable.playerClient), de);
                return de.Open;
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
            return false;
        }
Exemplo n.º 37
0
 private object OnItemDeployedByPlayer(DeployableObject component, IDeployableItem item)
 {
     return Interface.CallHook("OnItemDeployed", component, item.controllable.netUser);
 }
Exemplo n.º 38
0
 void NewObject()
 {
     lastObject = NetCull.InstantiateStatic(";deploy_wood_box", nextForward + heightAdjusment, character.rotation).GetComponent<DeployableObject>();
     lastObject.SetupCreator(character.controllable);
 }
Exemplo n.º 39
0
 public static void DeployableUCH(IDMain idMain, DeployableObject deployableObject)
 {
     TakeDamage component = idMain.GetComponent<TakeDamage>();
     if (component != null)
     {
         float health = component.health;
         NetEntityID entID = NetEntityID.Get((UnityEngine.MonoBehaviour)deployableObject);
         NetCull.RemoveRPCsByName(entID, "ClientHealthUpdate");
         if (!beingDestroyed.Contains(idMain.gameObject))
             NetCull.RPC<float>(entID, "ClientHealthUpdate", uLink.RPCMode.OthersBuffered, health);
         else
             beingDestroyed.Remove(idMain.gameObject);
     }
 }
Exemplo n.º 40
0
 internal DeployableObject[] Filter(DeployableObject[] shelters, string id)
 {
     return (from s in shelters
                 where s.ownerID.ToString() == id
                 select s).ToArray<DeployableObject>();
 }
Exemplo n.º 41
0
        public static void DeployableKilled(DeployableObject DO)
        {
            if (DO.handleDeathHere)
            {
                if (DO.clientDeathEffect != null)
                {
                    NetCull.RPC(NetEntityID.Get((UnityEngine.MonoBehaviour)DO), "Client_OnKilled", uLink.RPCMode.OthersBuffered);
                }
                NetCull.Destroy(DO.gameObject);
                if (DO.corpseObject != null)
                {
                    bool b = true;
                    if (!doorStops && (DO.corpseObject.name == "MetalDoor_Corpse" || DO.corpseObject.name == "WoodDoor_Corpse"))
                        b = false;

                    if (b)
                        NetCull.InstantiateStatic(DO.corpseObject, DO.transform.position, DO.transform.rotation);
                }
            }
        }
Exemplo n.º 42
0
 private void OnItemDeployed(DeployableObject component, NetUser user)
 {
     HookCalled("OnItemDeployed");
     // TODO: Print item deployed
 }
Exemplo n.º 43
0
 private void OnItemDeployed(DeployableObject component, NetUser netUser)
 {
     HookCalled("OnItemDeployed");
     // Print item deployed
     Puts(netUser.displayName + " deployed a " + component.name);
 }
Exemplo n.º 44
0
 /////////////////////////////////////////
 // OnItemDeployed(Deployer deployer, BaseEntity deployedEntity)
 // Called when an item was deployed
 /////////////////////////////////////////
 void OnItemDeployedByPlayer(DeployableObject deployedEntity, IDeployableItem deployableItem)
 {
     if (deployableItem.controllable == null) return;
     if (hasTag(deployableItem.controllable.playerClient, "nodeploy"))
     {
         if (!hasPermission(deployableItem.controllable.playerClient, "candeploy"))
         {
             timer.Once(0.01f, () => DestroyObject(deployedEntity.gameObject));
             SendMessage(deployableItem.controllable.playerClient, "You are not allowed to deploy here");
         }
     }
     else if(deployedEntity.GetComponent<TimedExplosive>())
     {
         timer.Once(4f, () => CheckPositionExplosive(deployedEntity, deployableItem));
     }
 }
Exemplo n.º 45
0
 void CheckPositionExplosive(DeployableObject deployedEntity, IDeployableItem deployableItem)
 {
     var objects = GameObject.FindObjectsOfType(typeof(Zone));
     if (objects != null)
         foreach (Zone zone in objects)
         {
             if (zone.info.undestr == null) continue;
             if(Vector3.Distance(deployedEntity.transform.position, zone.info.Location.GetPosition()) < (zone.info.Location.GetRadius() + 5f))
             {
                 deployableItem.character.GetComponent<Inventory>().AddItemAmount(deployableItem.datablock, 1);
                 NetCull.Destroy(deployedEntity.gameObject);
             }
         }
 }