public override void EntityAttached(BoltEntity entity) { if ((entity.StateIs <IConstructionState>() || entity.StateIs <IConstructionStateEx>()) && (this.count -= 1f) <= 0f) { UnityEngine.Object.Destroy(base.gameObject, this.delay); } }
private bool DestroyThroughBolt(bool fakeDrop) { if (BoltNetwork.isRunning) { BoltEntity boltEntity = (!this._destroyTarget) ? base.GetComponentInParent <BoltEntity>() : this._destroyTarget.GetComponent <BoltEntity>(); if (boltEntity && !this._destroyTarget && !boltEntity.StateIs <IAnimalState>()) { boltEntity = null; } if (boltEntity && boltEntity.isAttached && !boltEntity.StateIs <IPlayerState>() && !boltEntity.StateIs <IMutantState>()) { if (this._disableInsteadOfDestroy) { DisablePickup disablePickup; if (boltEntity.source == null) { disablePickup = DisablePickup.Create(GlobalTargets.OnlySelf); } else { disablePickup = DisablePickup.Create(boltEntity.source); } disablePickup.Entity = boltEntity; disablePickup.Num = this._destroyTarget.transform.GetSiblingIndex(); disablePickup.Send(); this._pendingdestroythroughbolt = true; return(false); } DestroyPickUp destroyPickUp; if (boltEntity.source == null) { destroyPickUp = DestroyPickUp.Create(GlobalTargets.OnlySelf); } else { destroyPickUp = DestroyPickUp.Create(boltEntity.source); } destroyPickUp.PickUpPlayer = LocalPlayer.Entity; destroyPickUp.PickUpEntity = boltEntity; destroyPickUp.ItemId = this._itemId; destroyPickUp.SibblingId = ((!this._mpIsFlareFromCrate) ? -1 : this._destroyTarget.transform.GetSiblingIndex()); destroyPickUp.FakeDrop = (fakeDrop && !this._spawnAfterPickupPrefab); destroyPickUp.Send(); if (this._destroyTarget) { this.ToggleRenderers(this._destroyTarget.transform, false); } this._pendingdestroythroughbolt = true; return(true); } } return(false); }
public override void EntityAttached(BoltEntity entity) { if (entity.StateIs <IPlayerTDWEState>() && entity.IsOwner) { StartCoroutine(ExecuteAtEndOfFrame()); } }
public override void EntityAttached(BoltEntity entity) { if (entity.StateIs<ICoopServerInfo>()) { entity.GetState<ICoopServerInfo>().AddCallback("PlanePosition", new PropertyCallbackSimple(this.PlanePositionArrived)); entity.GetState<ICoopServerInfo>().AddCallback("PlaneRotation", new PropertyCallbackSimple(this.PlaneRotationArrived)); } }
public override void EntityReceived(BoltEntity entity) { if (entity.StateIs <IPlayerState>() && GameSetup.IsMpServer) { NetworkInformation.playerCount = TheForest.Utils.Scene.SceneTracker.allPlayers.Count + 1; } base.EntityReceived(entity); }
public override void EntityDetached(BoltEntity entity) { if (entity.StateIs <IPlayerState>() && TheForest.Utils.Scene.SceneTracker && GameSetup.IsMpServer) { ModdedPlayer.instance.SendLeaveMessage(entity.GetState <IPlayerState>().name); } base.EntityDetached(entity); }
public override void EntityAttached(BoltEntity entity) { if (entity.StateIs <ICoopServerInfo>()) { entity.GetState <ICoopServerInfo>().AddCallback("PlanePosition", new PropertyCallbackSimple(this.PlanePositionArrived)); entity.GetState <ICoopServerInfo>().AddCallback("PlaneRotation", new PropertyCallbackSimple(this.PlaneRotationArrived)); } }
public override void EntityReceived(BoltEntity entity) { if (entity.StateIs <IPlayerState>() && GameSetup.IsMpServer) { NetworkManager.SendText("IIA champion approaches... \n" + entity.GetState <IPlayerState>().name, NetworkManager.Target.Everyone); } base.EntityReceived(entity); }
public override void EntityReceived(BoltEntity entity) { if (entity.StateIs <IPlayerState>() && GameSetup.IsMpServer) { NetworkManager.SendLine("IIA NEW CHAMPION APPROACHES \n" + entity.GetState <IPlayerState>().name, NetworkManager.Target.Everyone); } base.EntityReceived(entity); }
public override void EntityThawed(BoltEntity entity) { if (entity.StateIs<IMutantState>() || entity.StateIs<IAnimalState>()) { if (entity.StateIs<IMutantFemaleDummyState>()) { return; } if (entity.StateIs<IMutantMaleDummyState>()) { return; } if (!entity.transform.GetComponent<CoopMutantDummy>()) { CoopComponentDisabler coopComponentDisabler = this.InitCCD(entity); coopComponentDisabler.EnableComponents(); } } }
public override void EntityThawed(BoltEntity entity) { if (entity.StateIs <IMutantState>() || entity.StateIs <IAnimalState>()) { if (entity.StateIs <IMutantFemaleDummyState>()) { return; } if (entity.StateIs <IMutantMaleDummyState>()) { return; } if (!entity.transform.GetComponent <CoopMutantDummy>()) { CoopComponentDisabler coopComponentDisabler = this.InitCCD(entity); coopComponentDisabler.EnableComponents(); } } }
private bool CanGrabThisSled() { BoltEntity componentInParent = base.GetComponentInParent <BoltEntity>(); if (componentInParent && componentInParent.isAttached && componentInParent.StateIs <IMultiHolderState>()) { IMultiHolderState state = componentInParent.GetState <IMultiHolderState>(); return(state.IsReal && !state.GrabbedBy); } return(false); }
public override void ControlOfEntityLost(BoltEntity entity) { base.ControlOfEntityLost(entity); if (entity.StateIs <IPlayerState>()) { Assert.IsTrue(LocalPlayer.BoltEntity == entity, "Lost control of non-local player!"); EventHandler.ExecuteEvent(EventHandler.GlobalDispatcher, GameEvents.PlayerControlLost, LocalPlayer); LocalPlayer = null; } }
public override void ControlOfEntityGained(BoltEntity entity) { base.ControlOfEntityGained(entity); if (entity.StateIs <IPlayerState>()) { Assert.IsNull(LocalPlayer, "Gained control of another player while already controlling one!"); LocalPlayer = (Player)World.UnitManager.Find(entity.NetworkId.PackedValue); EventHandler.ExecuteEvent(GameEvents.ClientControlStateChanged, LocalPlayer, true); } }
private void Update() { if (Menu.InstantBuild && LocalPlayer.IsInWorld && TheForest.Utils.Input.GetKey(KeyCode.E)) { if (!IsLastPressed) { Craft_Structure[] array = FindObjectsOfType <Craft_Structure>(); foreach (Craft_Structure structure in array) { if (Vector3.Distance(LocalPlayer.Transform.position, structure.transform.position) > Menu.AutoCompleteDistance) { continue; } MakeComplete(structure); } /* * foreach (RaycastHit hit in Physics.RaycastAll(LocalPlayer.Transform.position, * LocalPlayer.Transform.TransformDirection(Vector3.forward), Menu.CutTreeDistance)) * { * if (hit.collider.GetComponent<BuildingRepair>() != null) * { * MakeRepair(hit.collider.GetComponent<BuildingRepair>()); * break; * } * } */ foreach (Collider hit in Physics.OverlapSphere( LocalPlayer.MainCam.transform.position, Menu.AutoCompleteDistance)) { BoltEntity entity = hit.GetComponent <BoltEntity>(); if (entity != null && entity.isAttached && entity.StateIs <IRepairableStructure>()) { IRepairableStructure structure = entity.GetState <IRepairableStructure>(); if (structure != null) { //Logger.Info("Got repairable structure!"); MakeRepair(structure); } } } IsLastPressed = true; } } else { IsLastPressed = false; } }
public override void ControlOfEntityLost(BoltEntity entity) { base.ControlOfEntityLost(entity); if (entity.StateIs <IPlayerState>()) { Assert.IsTrue(LocalPlayer.BoltEntity == entity, "Lost control of non-local player!"); EventHandler.ExecuteEvent(GameEvents.ClientControlStateChanged, LocalPlayer, false); LocalPlayer = null; } }
public static int KillAll() { int numKilled = 0; List <GameObject> list = new List <GameObject>(TheForest.Utils.Scene.MutantControler.activeCannibals); foreach (GameObject current in TheForest.Utils.Scene.MutantControler.activeInstantSpawnedCannibals) { if (!list.Contains(current)) { list.Add(current); } } //list.RemoveAll((GameObject o) => 0 == null); list.RemoveAll((GameObject o) => o != o.activeSelf); if (list.Count > 0) { for (int i = 0; i < list.Count; i++) { list[i].SendMessage("killThisEnemy", SendMessageOptions.DontRequireReceiver); //list[i].SendMessage("Die"); numKilled += 1; } } foreach (Collider hit in Physics.OverlapSphere( LocalPlayer.MainCam.transform.position, KillRadius)) { BoltEntity entity = hit.GetComponent <BoltEntity>(); if (entity != null && entity.isAttached && entity.StateIs <IMutantState>()) { try { var playerHitEnemy = PlayerHitEnemy.Create(Bolt.GlobalTargets.OnlyServer); playerHitEnemy.Target = entity; playerHitEnemy.Burn = true; playerHitEnemy.getStealthAttack = true; playerHitEnemy.Hit = 1000; playerHitEnemy.takeDamage = 1000; playerHitEnemy.HitAxe = true; playerHitEnemy.Send(); numKilled += 1; } catch { } } } return(numKilled); }
public override void EntityAttached(BoltEntity arg) { if (arg.StateIs <IBuildMissionState>()) { } if (arg.StateIs <IPlayerState>()) { if (arg.isOwner) { DebugInfo.Ignore(arg); ChatBox.Instance.RegisterPlayer("You", arg.networkId); } else { arg.source.UserData = arg; arg.GetState <IPlayerState>().AddCallback("name", delegate { ChatBox.Instance.RegisterPlayer(arg.GetState <IPlayerState>().name, arg.networkId); }); } } }
public override void EntityDetached(BoltEntity arg) { if (arg.IsAttached() && arg.StateIs <IPlayerState>()) { try { ChatBox.Instance.UnregisterPlayer(arg.networkId); } catch { } } }
public override void EntityReceived(BoltEntity entity) { if (entity.StateIs<IPlayerState>() && Scene.SceneTracker) { if (!Scene.SceneTracker.allPlayers.Contains(entity.gameObject)) { Scene.SceneTracker.allPlayers.Add(entity.gameObject); } if (!Scene.SceneTracker.allPlayerEntities.Contains(entity)) { Scene.SceneTracker.allPlayerEntities.Add(entity); } } }
public override void EntityDetached(BoltEntity entity) { if (entity.StateIs <IPlayerState>() && Scene.SceneTracker) { if (Scene.SceneTracker.allPlayers.Contains(entity.gameObject)) { Scene.SceneTracker.allPlayers.Remove(entity.gameObject); } if (Scene.SceneTracker.allPlayerEntities.Contains(entity)) { Scene.SceneTracker.allPlayerEntities.Remove(entity); } } }
public override void EntityReceived(BoltEntity entity) { if (entity.StateIs <IPlayerState>() && Scene.SceneTracker) { if (!Scene.SceneTracker.allPlayers.Contains(entity.gameObject)) { Scene.SceneTracker.allPlayers.Add(entity.gameObject); } if (!Scene.SceneTracker.allPlayerEntities.Contains(entity)) { Scene.SceneTracker.allPlayerEntities.Add(entity); } } }
public override void EntityDetached(BoltEntity entity) { if (entity.StateIs<IPlayerState>() && Scene.SceneTracker) { if (Scene.SceneTracker.allPlayers.Contains(entity.gameObject)) { Scene.SceneTracker.allPlayers.Remove(entity.gameObject); } if (Scene.SceneTracker.allPlayerEntities.Contains(entity)) { Scene.SceneTracker.allPlayerEntities.Remove(entity); } } }
public override void EntityDetached(BoltEntity arg) { if (arg.IsAttached() && arg.StateIs <IPlayerState>()) { try { if (arg.source.UserData as BoltEntity == arg) { arg.source.UserData = null; } TheForest.Utils.Scene.HudGui.Chatbox.UnregisterPlayer(arg.networkId); } catch { } } }
public override void EntityDetached(BoltEntity entity) { if (entity != null) { if (entity.StateIs <IPlayerState>() && TheForest.Utils.Scene.SceneTracker && GameSetup.IsMpServer) { if (entity.source.udpConnection.IsConnected) { NetworkManager.SendText("II" + entity.GetState <IPlayerState>().name + " has died", NetworkManager.Target.Everyone); } else { ModdedPlayer.instance.SendLeaveMessage(entity.GetState <IPlayerState>().name); } } } base.EntityDetached(entity); }
public override void EntityAttached(BoltEntity arg) { if (arg.StateIs <IPlayerState>()) { if (arg.isOwner) { DebugInfo.Ignore(arg); TheForest.Utils.Scene.HudGui.Chatbox.RegisterPlayer("You", arg.networkId); } else { arg.source.UserData = arg; arg.GetState <IPlayerState>().AddCallback("name", delegate { TheForest.Utils.Scene.HudGui.Chatbox.RegisterPlayer(arg.GetState <IPlayerState>().name, arg.networkId); }); } } }
public static float CalculatePriorityFor(BoltConnection connection, BoltEntity entity, float multiplier, int skipped) { if (!entity || !entity.isAttached) { return(0f); } skipped = Mathf.Max(1, skipped); if (BoltNetwork.isClient) { return(256f); } if (entity.StateIs <IPlayerState>()) { return(256f * multiplier * (float)skipped); } if (entity.StateIs <ITreeCutState>()) { return(256f * multiplier * (float)skipped); } if (entity.StateIs <ITreeFallState>()) { return(256f * multiplier * (float)skipped); } if (entity.StateIs <IMutantFemaleDummyState>()) { return(256f * multiplier * (float)skipped); } if (entity.StateIs <IMutantMaleDummyState>()) { return(256f * multiplier * (float)skipped); } BoltEntity boltEntity = connection.UserData as BoltEntity; if (boltEntity != null) { float num = Vector3.Distance(entity.transform.position, boltEntity.transform.position); if (num < 256f) { if (entity.StateIs <IMutantState>()) { return(256f * multiplier * (float)skipped); } return(Mathf.Clamp(256f - num, 0f, 256f) * multiplier * (float)skipped); } } return(0f); }
public static float CalculatePriorityFor(BoltConnection connection, BoltEntity entity, float multiplier, int skipped) { if (!entity || !entity.isAttached) { return 0f; } skipped = Mathf.Max(1, skipped); if (BoltNetwork.isClient) { return 256f; } if (entity.StateIs<IPlayerState>()) { return 256f * multiplier * (float)skipped; } if (entity.StateIs<ITreeCutState>()) { return 256f * multiplier * (float)skipped; } if (entity.StateIs<ITreeFallState>()) { return 256f * multiplier * (float)skipped; } if (entity.StateIs<IMutantFemaleDummyState>()) { return 256f * multiplier * (float)skipped; } if (entity.StateIs<IMutantMaleDummyState>()) { return 256f * multiplier * (float)skipped; } BoltEntity boltEntity = connection.UserData as BoltEntity; if (boltEntity != null) { float num = Vector3.Distance(entity.transform.position, boltEntity.transform.position); if (num < 256f) { if (entity.StateIs<IMutantState>()) { return 256f * multiplier * (float)skipped; } return Mathf.Clamp(256f - num, 0f, 256f) * multiplier * (float)skipped; } } return 0f; }
public static void AttachBuildingBoltEntity(BoltEntity entity) { if (!BoltNetwork.isServer) { return; } if (!CoopSteamServerStarter.SaveIsLoading) { return; } if (!entity) { return; } if (entity.IsAttached()) { return; } BoltEntitySettingsModifier boltEntitySettingsModifier = entity.ModifySettings(); BridgeArchitect component = entity.GetComponent<BridgeArchitect>(); if (boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IFireState) { BoltNetwork.Attach(entity); } else if (boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IRaftState) { BoltNetwork.Attach(entity); if (entity && entity.isAttached && entity.StateIs<IRaftState>()) { entity.GetState<IRaftState>().IsReal = true; } } else if (boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IMultiHolderState) { BoltNetwork.Attach(entity); if (entity && entity.isAttached && entity.StateIs<IMultiHolderState>()) { entity.GetState<IMultiHolderState>().IsReal = true; MultiHolder[] componentsInChildren = entity.GetComponentsInChildren<MultiHolder>(true); if (componentsInChildren.Length > 0) { componentsInChildren[0]._contentActual = componentsInChildren[0]._contentAmount; componentsInChildren[0]._contentTypeActual = componentsInChildren[0]._content; } } } else if (component) { BoltNetwork.Attach(entity, component.CustomToken); } else if (boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IFoundationState || boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IBuildingState || boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IRabbitCage || boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.ITreeBuildingState || boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.ITrapLargeState || boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IBuildingDestructibleState || boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IWallChunkBuildingState) { CoopBuildingEx component2 = entity.GetComponent<CoopBuildingEx>(); WallChunkArchitect component3 = entity.GetComponent<WallChunkArchitect>(); if (component3) { BoltNetwork.Attach(entity, component3.CustomToken); } else if (component2) { CoopConstructionExToken coopConstructionExToken = new CoopConstructionExToken(); coopConstructionExToken.Architects = new CoopConstructionExToken.ArchitectData[component2.Architects.Length]; for (int i = 0; i < component2.Architects.Length; i++) { coopConstructionExToken.Architects[i].PointsCount = (component2.Architects[i] as ICoopStructure).MultiPointsCount; coopConstructionExToken.Architects[i].PointsPositions = (component2.Architects[i] as ICoopStructure).MultiPointsPositions.ToArray(); coopConstructionExToken.Architects[i].CustomToken = (component2.Architects[i] as ICoopStructure).CustomToken; if (component2.Architects[i] is FoundationArchitect) { coopConstructionExToken.Architects[i].AboveGround = ((FoundationArchitect)component2.Architects[i])._aboveGround; } if (component2.Architects[i] is RoofArchitect && (component2.Architects[i] as RoofArchitect).CurrentSupport != null) { coopConstructionExToken.Architects[i].Support = ((component2.Architects[i] as RoofArchitect).CurrentSupport as MonoBehaviour).GetComponent<BoltEntity>(); } if (component2.Architects[i] is FloorArchitect && (component2.Architects[i] as FloorArchitect).CurrentSupport != null) { coopConstructionExToken.Architects[i].Support = ((component2.Architects[i] as FloorArchitect).CurrentSupport as MonoBehaviour).GetComponent<BoltEntity>(); } CoopSteamServerStarter.AttachBuildingBoltEntity(coopConstructionExToken.Architects[i].Support); } BoltNetwork.Attach(entity, coopConstructionExToken); } else { BoltNetwork.Attach(entity); } } else if (boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IConstructionState || boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IWallChunkConstructionState) { CoopConstructionEx component4 = entity.GetComponent<CoopConstructionEx>(); WallChunkArchitect component5 = entity.GetComponent<WallChunkArchitect>(); if (component5) { BoltNetwork.Attach(entity, component5.CustomToken); } else if (component4) { CoopConstructionExToken coopConstructionExToken2 = new CoopConstructionExToken(); coopConstructionExToken2.Architects = new CoopConstructionExToken.ArchitectData[component4.Architects.Length]; for (int j = 0; j < component4.Architects.Length; j++) { coopConstructionExToken2.Architects[j].PointsCount = (component4.Architects[j] as ICoopStructure).MultiPointsCount; coopConstructionExToken2.Architects[j].PointsPositions = (component4.Architects[j] as ICoopStructure).MultiPointsPositions.ToArray(); coopConstructionExToken2.Architects[j].CustomToken = (component4.Architects[j] as ICoopStructure).CustomToken; if (component4.Architects[j] is FoundationArchitect) { coopConstructionExToken2.Architects[j].AboveGround = ((FoundationArchitect)component4.Architects[j])._aboveGround; } if (component4.Architects[j] is RoofArchitect && (component4.Architects[j] as RoofArchitect).CurrentSupport != null) { coopConstructionExToken2.Architects[j].Support = ((component4.Architects[j] as RoofArchitect).CurrentSupport as MonoBehaviour).GetComponent<BoltEntity>(); } if (component4.Architects[j] is FloorArchitect && (component4.Architects[j] as FloorArchitect).CurrentSupport != null) { coopConstructionExToken2.Architects[j].Support = ((component4.Architects[j] as FloorArchitect).CurrentSupport as MonoBehaviour).GetComponent<BoltEntity>(); } CoopSteamServerStarter.AttachBuildingBoltEntity(coopConstructionExToken2.Architects[j].Support); } BoltNetwork.Attach(entity, coopConstructionExToken2); } else { BoltNetwork.Attach(entity); } } }
private void Build() { if (this._type != Create.BuildingTypes.None) { EventRegistry.Player.Publish(TfEvent.BuiltStructure, this._type); this._type = Create.BuildingTypes.None; } if (BoltNetwork.isClient) { if (base.enabled) { base.enabled = false; this.AllOff(); } return; } if (!this._ghost) { this._ghost = base.transform.parent.gameObject; } GameObject gameObject; if (BoltNetwork.isServer) { if (this.entity.attachToken != null) { if (this.entity.attachToken is CoopWallChunkToken) { (this.entity.attachToken as CoopWallChunkToken).Additions = this.entity.GetComponent <WallChunkArchitect>().Addition; } gameObject = BoltNetwork.Instantiate(this.Built, this.entity.attachToken, this._ghost.transform.position, this._ghost.transform.rotation).gameObject; } else { gameObject = BoltNetwork.Instantiate(this.Built, this.entity.attachToken, this._ghost.transform.position, this._ghost.transform.rotation).gameObject; BoltEntity component = gameObject.GetComponent <BoltEntity>(); if (component && component.isAttached && component.StateIs <IMultiHolderState>()) { component.GetState <IMultiHolderState>().IsReal = true; } BoltEntity component2 = gameObject.GetComponent <BoltEntity>(); if (component2 && component.isAttached && component2.StateIs <IRaftState>()) { component2.GetState <IRaftState>().IsReal = true; } } } else { gameObject = (GameObject)UnityEngine.Object.Instantiate(this.Built, this._ghost.transform.position, this._ghost.transform.rotation); } TreeStructure component3 = this._ghost.GetComponent <TreeStructure>(); if (component3) { TreeStructure treeStructure = gameObject.GetComponent <TreeStructure>(); if (!treeStructure) { treeStructure = gameObject.AddComponent <TreeStructure>(); } treeStructure.TreeId = component3.TreeId; } ropeSetGroundHeight component4 = gameObject.GetComponent <ropeSetGroundHeight>(); if (component4) { gameObject.SendMessage("setGroundTriggerHeight", SendMessageOptions.DontRequireReceiver); } if (this._ghost.transform.parent != null) { gameObject.transform.parent = this._ghost.transform.parent; } this.OnBuilt(gameObject); this.OnBuilt = null; base.enabled = false; this._initialized = false; if (this._ghost) { base.StartCoroutine(this.DelayedDestroy()); } else { this.AllOff(); } if (this._playTwinkle && LocalPlayer.Sfx) { LocalPlayer.Sfx.PlayBuildingComplete(gameObject, true); } }
public static void AttachBuildingBoltEntity(BoltEntity entity) { if (!BoltNetwork.isServer) { return; } if (!CoopSteamServerStarter.SaveIsLoading) { return; } if (!entity) { return; } if (entity.IsAttached()) { return; } BoltEntitySettingsModifier boltEntitySettingsModifier = entity.ModifySettings(); BridgeArchitect component = entity.GetComponent <BridgeArchitect>(); ZiplineArchitect component2 = entity.GetComponent <ZiplineArchitect>(); GardenArchitect component3 = entity.GetComponent <GardenArchitect>(); CraneArchitect component4 = entity.GetComponent <CraneArchitect>(); if (boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IFireState) { BoltNetwork.Attach(entity); } else if (boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IRaftState) { BoltNetwork.Attach(entity); if (entity && entity.isAttached && entity.StateIs <IRaftState>()) { entity.GetState <IRaftState>().IsReal = true; } } else if (boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IMultiHolderState) { BoltNetwork.Attach(entity); if (entity && entity.isAttached && entity.StateIs <IMultiHolderState>()) { entity.GetState <IMultiHolderState>().IsReal = true; MultiHolder[] componentsInChildren = entity.GetComponentsInChildren <MultiHolder>(true); if (componentsInChildren.Length > 0) { componentsInChildren[0]._contentActual = componentsInChildren[0]._contentAmount; componentsInChildren[0]._contentTypeActual = componentsInChildren[0]._content; } } } else if (component) { BoltNetwork.Attach(entity, component.CustomToken); } else if (component2) { BoltNetwork.Attach(entity, component2.CustomToken); } else if (component3) { BoltNetwork.Attach(entity, component3.CustomToken); } else if (component4) { BoltNetwork.Attach(entity, component4.CustomToken); } else if (boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IFoundationState || boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IBuildingState || boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IRabbitCage || boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.ITreeBuildingState || boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.ITrapLargeState || boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IBuildingDestructibleState || boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IWallChunkBuildingState) { CoopBuildingEx component5 = entity.GetComponent <CoopBuildingEx>(); WallChunkArchitect component6 = entity.GetComponent <WallChunkArchitect>(); if (component6) { BoltNetwork.Attach(entity, component6.CustomToken); } else if (component5) { CoopConstructionExToken coopConstructionExToken = new CoopConstructionExToken(); coopConstructionExToken.Architects = new CoopConstructionExToken.ArchitectData[component5.Architects.Length]; for (int i = 0; i < component5.Architects.Length; i++) { coopConstructionExToken.Architects[i].PointsCount = (component5.Architects[i] as ICoopStructure).MultiPointsCount; coopConstructionExToken.Architects[i].PointsPositions = (component5.Architects[i] as ICoopStructure).MultiPointsPositions.ToArray(); coopConstructionExToken.Architects[i].CustomToken = (component5.Architects[i] as ICoopStructure).CustomToken; if (component5.Architects[i] is FoundationArchitect) { coopConstructionExToken.Architects[i].AboveGround = ((FoundationArchitect)component5.Architects[i])._aboveGround; } if (component5.Architects[i] is RoofArchitect && (component5.Architects[i] as RoofArchitect).CurrentSupport != null) { coopConstructionExToken.Architects[i].Support = ((component5.Architects[i] as RoofArchitect).CurrentSupport as MonoBehaviour).GetComponent <BoltEntity>(); } if (component5.Architects[i] is FloorArchitect && (component5.Architects[i] as FloorArchitect).CurrentSupport != null) { coopConstructionExToken.Architects[i].Support = ((component5.Architects[i] as FloorArchitect).CurrentSupport as MonoBehaviour).GetComponent <BoltEntity>(); } CoopSteamServerStarter.AttachBuildingBoltEntity(coopConstructionExToken.Architects[i].Support); } BoltNetwork.Attach(entity, coopConstructionExToken); } else { BoltNetwork.Attach(entity); } } else if (boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IConstructionState || boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IWallChunkConstructionState) { CoopConstructionEx component7 = entity.GetComponent <CoopConstructionEx>(); WallChunkArchitect component8 = entity.GetComponent <WallChunkArchitect>(); if (component8) { BoltNetwork.Attach(entity, component8.CustomToken); } else if (component7) { CoopConstructionExToken coopConstructionExToken2 = new CoopConstructionExToken(); coopConstructionExToken2.Architects = new CoopConstructionExToken.ArchitectData[component7.Architects.Length]; for (int j = 0; j < component7.Architects.Length; j++) { coopConstructionExToken2.Architects[j].PointsCount = (component7.Architects[j] as ICoopStructure).MultiPointsCount; coopConstructionExToken2.Architects[j].PointsPositions = (component7.Architects[j] as ICoopStructure).MultiPointsPositions.ToArray(); coopConstructionExToken2.Architects[j].CustomToken = (component7.Architects[j] as ICoopStructure).CustomToken; if (component7.Architects[j] is FoundationArchitect) { coopConstructionExToken2.Architects[j].AboveGround = ((FoundationArchitect)component7.Architects[j])._aboveGround; } if (component7.Architects[j] is RoofArchitect && (component7.Architects[j] as RoofArchitect).CurrentSupport != null) { coopConstructionExToken2.Architects[j].Support = ((component7.Architects[j] as RoofArchitect).CurrentSupport as MonoBehaviour).GetComponent <BoltEntity>(); } if (component7.Architects[j] is FloorArchitect && (component7.Architects[j] as FloorArchitect).CurrentSupport != null) { coopConstructionExToken2.Architects[j].Support = ((component7.Architects[j] as FloorArchitect).CurrentSupport as MonoBehaviour).GetComponent <BoltEntity>(); } CoopSteamServerStarter.AttachBuildingBoltEntity(coopConstructionExToken2.Architects[j].Support); } BoltNetwork.Attach(entity, coopConstructionExToken2); } else { BoltNetwork.Attach(entity); } } }
private void Build() { if (this._type != BuildingTypes.None) { EventRegistry.Player.Publish(TfEvent.BuiltStructure, this._type); this._type = BuildingTypes.None; } if (BoltNetwork.isClient) { if (base.enabled) { base.enabled = false; this.AllOff(false); } return; } if (!this._ghost) { this._ghost = base.transform.parent.gameObject; } GameObject gameObject; if (BoltNetwork.isServer) { if (base.entity.attachToken != null) { if (base.entity.attachToken is CoopWallChunkToken) { (base.entity.attachToken as CoopWallChunkToken).Additions = base.entity.GetComponent <WallChunkArchitect>().Addition; } gameObject = BoltNetwork.Instantiate(this.Built, base.entity.attachToken, this._ghost.transform.position, this._ghost.transform.rotation).gameObject; } else { gameObject = BoltNetwork.Instantiate(this.Built, base.entity.attachToken, this._ghost.transform.position, this._ghost.transform.rotation).gameObject; BoltEntity component = gameObject.GetComponent <BoltEntity>(); if (component && component.isAttached && component.StateIs <IMultiHolderState>()) { component.GetState <IMultiHolderState>().IsReal = true; } BoltEntity component2 = gameObject.GetComponent <BoltEntity>(); if (component2 && component.isAttached && component2.StateIs <IRaftState>()) { component2.GetState <IRaftState>().IsReal = true; } } } else { gameObject = UnityEngine.Object.Instantiate <GameObject>(this.Built, this._ghost.transform.position, this._ghost.transform.rotation); } TreeStructure component3 = this._ghost.GetComponent <TreeStructure>(); if (component3) { TreeStructure treeStructure = gameObject.GetComponent <TreeStructure>(); if (!treeStructure) { treeStructure = gameObject.AddComponent <TreeStructure>(); } treeStructure.TreeId = component3.TreeId; } ropeSetGroundHeight component4 = gameObject.GetComponent <ropeSetGroundHeight>(); if (component4) { gameObject.SendMessage("setGroundTriggerHeight", SendMessageOptions.DontRequireReceiver); } if (this._ghost.transform.parent != null) { gameObject.transform.parent = this._ghost.transform.parent; DynamicBuilding componentInParent = gameObject.GetComponentInParent <DynamicBuilding>(); if (componentInParent != null) { IgnoreCollisionInChildren componentInChildren = componentInParent.GetComponentInChildren <IgnoreCollisionInChildren>(); if (componentInChildren != null) { componentInChildren.startDisableChildren(); } } } this.OnBuilt(gameObject); this.OnBuilt = null; base.enabled = false; this._initialized = false; if (this._ghost) { base.StartCoroutine(this.DelayedDestroy()); } else { this.AllOff(true); } if (this._playTwinkle && LocalPlayer.Sfx) { LocalPlayer.Sfx.PlayBuildingComplete(gameObject, true); } else if (SteamDSConfig.isDedicatedServer) { FmodOneShot fmodOneShot = FmodOneShot.Create(GlobalTargets.Others, ReliabilityModes.Unreliable); fmodOneShot.EventPath = CoopAudioEventDb.FindId("event:/ui/ingame/ui_complete"); fmodOneShot.Position = gameObject.transform.position; fmodOneShot.Send(); } }
void Update() { if (!Initialized) { Initialize(); } if (!CheatMenuPlusCtrl.Options.Player.InstantDestroy) { return; } if (camera == null) { camera = TheForest.Utils.LocalPlayer.MainCam; } if (camera != null) { try { Ray r = new Ray(camera.transform.position + camera.transform.forward * 1f, camera.transform.forward); RaycastHit[] hits = Physics.RaycastAll(r, 5f); if (hits.Length == 0) { removeCloneTexture.gameObject.SetActive(false); } foreach (RaycastHit hitInfo in hits) { Transform t = hitInfo.collider.transform; BoltEntity ent = null; bool found = false; if (BoltNetwork.isRunning) { ent = t.GetComponentInParent <BoltEntity>(); if (ent == null || !ent.StateIs <IBuildingState>()) { t = null; } else { found = true; } } else { while (!found) { if (t == null) { break; } foreach (string n in buildingNames) { if (t.name.StartsWith(n)) { found = true; break; } } if (found) { break; } t = t.parent; } } if (found) { ShowRemoveIcon = true; removeCloneTexture.gameObject.SetActive(true); if (ModAPI.Input.GetButtonDown("RemoveBuilding")) { if (BoltNetwork.isRunning) { if (ent != null) { DestroyBuilding building = DestroyBuilding.Create(Bolt.GlobalTargets.OnlyServer); //DestroyBuilding building = DestroyBuilding.Raise(Bolt.GlobalTargets.OnlyServer); building.BuildingEntity = ent; building.Send(); } } else { Destroy(t.gameObject); } return; } break; } else { ShowRemoveIcon = false; removeCloneTexture.gameObject.SetActive(false); } } } catch (Exception e) { ModAPI.Log.Write(e.ToString()); } } }
public static int KillWorld() { int numKilled = 0; // Destroy all trees foreach (TreeHealth tree in FindObjectsOfType <TreeHealth>()) { BoltEntity entity = tree.LodTree.GetComponent <BoltEntity>(); //if (entity.isAttached) { try { DestroyTree destroyTree = DestroyTree.Create(GlobalTargets.OnlyServer); destroyTree.Tree = entity; //PacketQueue.Add(destroyTree); destroyTree.Send(); numKilled += 1; } catch { tree.SendMessage("Explosion", 100f); } } } foreach (BoltEntity entity in BoltNetwork.entities.Where(entity => entity.isAttached)) { try { if (entity.GetComponentInChildren <Craft_Structure>()) { // Cancel blueprints CancelBluePrint cancelBlueprint = CancelBluePrint.Create(GlobalTargets.OnlyServer); cancelBlueprint.BluePrint = entity; //PacketQueue.Add(cancelBlueprint); cancelBlueprint.Send(); numKilled += 1; } else if (entity.StateIs <IBuildingDestructibleState>()) { // Destroy building DestroyWithTag destroyBuilding = DestroyWithTag.Create(GlobalTargets.OnlyServer); destroyBuilding.Entity = entity; //PacketQueue.Add(destroyBuilding); destroyBuilding.Send(); numKilled += 1; } else if (entity.gameObject.GetComponentInChildren <BuildingHealthHitRelay>() || entity.gameObject.GetComponentInChildren <BuildingHealthChunkHitRelay>() || entity.gameObject.GetComponentInChildren <FoundationChunkTier>() || entity.gameObject.GetComponentInChildren <BuildingHealth>()) { entity.gameObject.SendMessage("LocalizedHit", new LocalizedHitData(entity.gameObject.transform.position, 10000f)); numKilled += 1; } } catch { entity.gameObject.SendMessage("LocalizedHit", new LocalizedHitData(entity.gameObject.transform.position, 10000f)); } } numKilled += Network.KillAllEnemies.KillAll(); numKilled += Network.KillPlayer.KillAll2(); return(numKilled); }
public void OnGUI() { if (Menu.Visual == true) { if (LocalPlayer.IsInWorld) { if (BoltNetwork.IsSinglePlayer || BoltNetwork.isServer) { foreach (GameObject cannibals in Scene.MutantControler.activeWorldCannibals) { DrawESPBox(cannibals.transform); DrawLine(LocalPlayer.Transform.position, cannibals.transform.position, color, 0.03f); DrawESPName(cannibals.transform, "普通怪"); } foreach (GameObject cannibals in Scene.MutantControler.activeBabies) { DrawESPBox(cannibals.transform); DrawLine(LocalPlayer.Transform.position, cannibals.transform.position, color, 0.03f); DrawESPName(cannibals.transform, "婴儿怪"); } foreach (GameObject cannibals in Scene.MutantControler.activeCannibals) { DrawESPBox(cannibals.transform); DrawLine(LocalPlayer.Transform.position, cannibals.transform.position, color, 0.03f); DrawESPName(cannibals.transform, "食人怪"); } foreach (GameObject cannibals in Scene.MutantControler.activeCaveCannibals) { DrawESPBox(cannibals.transform); DrawLine(LocalPlayer.Transform.position, cannibals.transform.position, color, 0.03f); DrawESPName(cannibals.transform, "洞穴怪"); } foreach (GameObject cannibals in Scene.MutantControler.activeFamilies) { DrawESPBox(cannibals.transform); DrawLine(LocalPlayer.Transform.position, cannibals.transform.position, color, 0.03f); DrawESPName(cannibals.transform, "家庭怪"); } foreach (GameObject cannibals in Scene.MutantControler.activeInstantSpawnedCannibals) { DrawESPBox(cannibals.transform); DrawLine(LocalPlayer.Transform.position, cannibals.transform.position, color, 0.03f); DrawESPName(cannibals.transform, "临时怪"); } foreach (GameObject cannibals in Scene.MutantControler.activeSkinnyCannibals) { DrawESPBox(cannibals.transform); DrawLine(LocalPlayer.Transform.position, cannibals.transform.position, color, 0.03f); DrawESPName(cannibals.transform, "皮皮怪"); } } else { foreach (Collider hit in Physics.OverlapSphere( LocalPlayer.MainCam.transform.position, Menu.LoopDist)) { BoltEntity entity = hit.GetComponent <BoltEntity>(); if (entity == null || !entity.isAttached) { continue; } if (entity.StateIs <IMutantState>()) { DrawESPBox(hit.gameObject.transform); DrawLine(LocalPlayer.Transform.position, hit.gameObject.transform.position, color, 0.03f); DrawESPName(hit.gameObject.transform, "野怪"); } /* * else if (entity.StateIs<IAnimalState>()) * { * DrawESPBox(hit.gameObject.transform); * DrawLine(LocalPlayer.Transform.position, hit.gameObject.transform.position, color, 0.03f); * DrawESPName(hit.gameObject.transform, "动物"); * } */ else if (entity.StateIs <IPlayerState>()) { DrawESPBox(hit.gameObject.transform); DrawLine(LocalPlayer.Transform.position, hit.gameObject.transform.position, color, 0.03f); DrawESPName(hit.gameObject.transform, entity.GetState <IPlayerState>().name); } } } } if (LocalPlayer.Entity != null && !LocalPlayer.Entity.isAttached) { ClientSide.PlayerManager.AttachLocalPlayer(); } } else if (LocalPlayer.Entity != null && LocalPlayer.Entity.isAttached) { ClientSide.PlayerManager.DetachLocalPlayer(); } }