public void On_Placement(BuildingEvent be) { if (StructureRecorder) { Player player = be.Builder; string name; if (DataStore.ContainsKey("StructureRecorder", player.SteamID)) { name = (string)DataStore.Get("StructureRecorder", player.SteamID); } else if (DataStore.ContainsKey("StructureRecorderEveryone", "ON")) { name = (string)DataStore.Get("StructureRecorderEveryone", "ON"); } else { return; } BuildingPart bp = be.BuildingPart; Structure structure; Structures.TryGetValue(name, out structure); if (structure == null) { return; } structure.AddComponent(bp); player.Message("Added " + bp.Name); } }
// Construiction.Common.CreateConstruction() public static BaseEntity On_Placement(Construction construction, Construction.Target target, bool bNeedsValidPlacement) { try { GameObject gameObject = GameManager.server.CreatePrefab(construction.fullName, default(Vector3), default(Quaternion), true); BuildingBlock component = gameObject.GetComponent <BuildingBlock>(); bool flag = construction.UpdatePlacement(gameObject.transform, construction, target); if (bNeedsValidPlacement && !flag) { UnityEngine.Object.Destroy(gameObject); return(null); } BuildingEvent be = null; if (component != null) { be = new BuildingEvent(construction, target, component, bNeedsValidPlacement); OnNext("On_Placement", be); } if (be != null && be.DoDestroy) { be.Builder.Message(be.DestroyReason); UnityEngine.Object.Destroy(gameObject); return(null); } return(gameObject.GetComponent <BaseEntity>()); } catch (Exception ex) { Logger.LogException(ex); return(null); } }
/// <summary> /// Called from <c>Construction.CreateConstruction(Construction.Target, bool)</c> . /// </summary> public static BaseEntity On_Placement(Construction construction, Construction.Target target, bool needsValidPlacement) { try { GameObject gameObject = GameManager.server.CreatePrefab(construction.fullName, default(Vector3), default(Quaternion), true); BuildingBlock component = gameObject.GetComponent<BuildingBlock>(); bool flag = construction.UpdatePlacement(gameObject.transform, construction, target); if (needsValidPlacement && !flag) { UnityEngine.Object.Destroy(gameObject); return null; } BuildingEvent be = null; if (component != null) { be = new BuildingEvent(construction, target, component, needsValidPlacement); OnNext("On_Placement", be); } if (be != null && be.DoDestroy) { be.Builder.Message(be.DestroyReason); UnityEngine.Object.Destroy(gameObject); return null; } return gameObject.GetComponent<BaseEntity>(); } catch (Exception ex) { Logger.LogException(ex); return null; } }
public void On_Placement(BuildingEvent be) { SetHookWorking("On_Placement"); Broadcast(be.BuildingPart.Name + " has been placed by " + be.Builder.Name); }
public void OnPlacement(BuildingEvent be) { this.Invoke("On_Placement", be); }
public void OnBuildingUpdate(BuildingEvent be) { this.Invoke("On_BuildingUpdate", be); }