private void GiveBackpackWorldmodel(BasePlayer player) { SphereEntity sph = GameManager.server.CreateEntity(spherePrefab, player.eyes.position, player.transform.rotation) as SphereEntity; sph.Spawn(); sph.lerpSpeed = 0f; sph.currentRadius = 0.6f; sph.SetParent(player, "spine3"); sph.transform.localPosition = new Vector3(-0.08f, 0, 0); sph.transform.rotation = Quaternion.Euler(0, 270, 180); DroppedItemContainer gObj = GameManager.server.CreateEntity(itemWorldModel, player.transform.position) as DroppedItemContainer; //PrintComponents(sph); gObj.ResetRemovalTime(9999999999999); //gObj.transform.localPosition = new Vector3(0, 0, 0); //gObj.transform.rotation = Quaternion.Euler(0, 270, 180); gObj.Spawn(); UnityEngine.Object.DestroyImmediate(gObj.GetComponent <Rigidbody>()); gObj.SetParent(sph); gObj.transform.localPosition = new Vector3(0, 0, 0); gObj.SendNetworkUpdateImmediate(); timer.Once(1.0f, () => { gObj.SetParent(player, "spine3"); gObj.transform.localPosition = new Vector3(-0.08f, 0.0f, 0); gObj.transform.rotation = Quaternion.Euler(0, 270, 180); timer.Once(0.2f, () => { sph?.Kill(); }); }); }
void OnDestroy() { CancelInvoke(); innerSphere.Kill(); outerSphere.Kill(); Destroy(gameObject); }
private NPCAutoTurret DeployNpcAutoTurret(Drone drone, BasePlayer deployer) { SphereEntity sphereEntity = SpawnSphereEntity(drone); if (sphereEntity == null) { return(null); } var turret = GameManager.server.CreateEntity(NpcAutoTurretPrefab) as NPCAutoTurret; if (turret == null) { sphereEntity.Kill(); return(null); } turret.SetParent(sphereEntity); turret.Spawn(); drone.SetSlot(TurretSlot, turret); SetupDroneTurret(drone, turret, sphereEntity); Effect.server.Run(DeployEffectPrefab, turret.transform.position); Interface.CallHook("OnDroneNpcTurretDeployed", drone, turret, deployer); return(turret); }
private AutoTurret DeployAutoTurret(Drone drone, BasePlayer basePlayer, float conditionFraction = 1) { SphereEntity sphereEntity = SpawnSphereEntity(drone); if (sphereEntity == null) { return(null); } var turret = GameManager.server.CreateEntity(AutoTurretPrefab) as AutoTurret; if (turret == null) { sphereEntity.Kill(); return(null); } if (basePlayer != null) { turret.OwnerID = basePlayer.userID; } turret.SetFlag(IOEntity.Flag_HasPower, true); turret.SetParent(sphereEntity); turret.Spawn(); turret.SetHealth(turret.MaxHealth() * conditionFraction); AttachTurretSwitch(turret); drone.SetSlot(TurretSlot, turret); SetupDroneTurret(drone, turret, sphereEntity); Effect.server.Run(DeployEffectPrefab, turret.transform.position); Interface.CallHook("OnDroneTurretDeployed", drone, turret, basePlayer); if (basePlayer == null) { return(turret); } turret.authorizedPlayers.Add(new ProtoBuf.PlayerNameID { userid = basePlayer.userID, username = basePlayer.displayName }); turret.SendNetworkUpdate(); // Allow other plugins to detect the auto turret being deployed (e.g., to add a weapon automatically). var turretItem = FindPlayerAutoTurretItem(basePlayer); if (turretItem != null) { RunOnEntityBuilt(turretItem, turret); } else { // Temporarily increase the player inventory capacity to ensure there is enough space. basePlayer.inventory.containerMain.capacity++; var temporaryTurretItem = ItemManager.CreateByItemID(AutoTurretItemId); if (basePlayer.inventory.GiveItem(temporaryTurretItem)) { RunOnEntityBuilt(temporaryTurretItem, turret); temporaryTurretItem.RemoveFromContainer(); } temporaryTurretItem.Remove(); basePlayer.inventory.containerMain.capacity--; } return(turret); }