/// <summary> /// Remove a gameObject from the Ascension simulation. /// </summary> public static void Destroy(GameObject gameObject, IMessageRider token) { if (IsRunning) { AscensionEntity entity = gameObject.GetComponent <AscensionEntity>(); if (entity) { Core.Destroy(entity, token); } else { if (token != null) { UnityEngine.Debug.LogWarning("Passing protocol token to destroy call for gameobject without ascension entity, token will be ignored"); } UnityEngine.Object.Destroy(gameObject); } } else { if (token != null) { UnityEngine.Debug.LogWarning("Passing protocol token to destroy call for gameobject when ascension is not running, token will be ignored"); } UnityEngine.Object.Destroy(gameObject); } }
/// <summary> /// Sets the parent of this entity /// </summary> public void SetParent(AscensionEntity parent) { if (parent && parent.IsAttached) { AEntity.SetParent(parent.AEntity); } else { AEntity.SetParent(null); } }
/// <summary> /// Create a new entity in the simuation from a prefab /// </summary> public static AscensionEntity Instantiate(GameObject prefab, IMessageRider token, Vector3 position, Quaternion rotation) { VerifyIsRunning(); AscensionEntity ae = prefab.GetComponent <AscensionEntity>(); if (!ae) { NetLog.Error("Prefab '{0}' does not have a Ascension Entity component attached", prefab.name); return(null); } if (ae.SerializerGuid == UniqueId.None) { NetLog.Error("Prefab '{0}' does not have a serializer assigned", prefab.name); return(null); } return(Core.Instantiate(new PrefabId(ae.prefabId), Factory.GetFactory(ae.SerializerGuid).TypeId, position, rotation, InstantiateFlags.ZERO, null, token)); }
void DrawEntity(AscensionEntity entity) { if (entity && entity.IsAttached) { Camera c = Camera.main; if (c) { Vector3 vp = c.WorldToViewportPoint(entity.transform.position); if (vp.z >= 0 && vp.x >= 0 && vp.x <= 1 && vp.y >= 0 && vp.y <= 1) { Vector3 sp = c.WorldToScreenPoint(entity.transform.position); Rect r = new Rect(sp.x - 8, (Screen.height - sp.y) - 8, 16, 16); DebugInfo.DrawBackground(r); GUI.DrawTexture(r, DebugInfo.AscensionIconTexture); } } } }
private static IEnumerable <NetworkPrefab> FindPrefabs() { var id = 1; var files = Directory.GetFiles(@"Assets", "*.prefab", SearchOption.AllDirectories); var settings = RuntimeSettings.Instance; for (int i = 0; i < files.Length; ++i) { AscensionEntity entity = AssetDatabase.LoadAssetAtPath(files[i], typeof(AscensionEntity)) as AscensionEntity; if (entity) { entity.prefabId = id; entity.sceneGuid = null; if (settings.clientCanInstantiateAll) { entity.allowInstantiateOnClient = true; } EditorUtility.SetDirty(entity.gameObject); EditorUtility.SetDirty(entity); yield return (new NetworkPrefab { go = entity.gameObject, id = id, name = entity.gameObject.name.CSharpIdentifier() }); id += 1; } EditorUtility.DisplayProgressBar("Updating Ascension Prefab Database", "Scanning for prefabs ...", Mathf.Clamp01((float)i / (float)files.Length)); } }
public static bool Contains(AscensionEntity entity) { if (Instance.Prefabs == null) { return(false); } if (!entity) { return(false); } if (entity.prefabId >= Instance.Prefabs.Length) { return(false); } if (entity.prefabId < 0) { return(false); } return(Instance.Prefabs[entity.prefabId] == entity.gameObject); }
public ExistsResult ExistsOnRemote(AscensionEntity entity) { return(entityChannel.ExistsOnRemote(entity.AEntity, false)); }
public AscensionEntitySettingsModifier(AscensionEntity entity) { this.entity = entity; }
public static bool IsControlled(this AscensionEntity entity) { return(entity.IsAttached() && entity.IsControlled); }
public static void WriteBoltEntity(this BasePacket packet, AscensionEntity entity) { WriteEntity(packet, entity == null ? null : entity.AEntity); }
public static bool IsAttached(this AscensionEntity entity) { return(AscensionNetwork.IsRunning && entity && entity.IsAttached); }
public static bool HasControl(this AscensionEntity entity) { return(entity.IsAttached() && entity.HasControl); }
public static bool IsFrozen(this AscensionEntity entity) { return(entity.IsAttached() && entity.IsFrozen); }
public static bool IsSceneObject(this AscensionEntity entity) { return(entity.IsAttached() && entity.IsSceneObject); }
public ExistsResult ExistsOnRemote(AscensionEntity entity, bool allowMaybe) { return(entityChannel.ExistsOnRemote(entity.AEntity, allowMaybe)); }
public int GetSkippedUpdates(AscensionEntity en) { return(entityChannel.GetSkippedUpdates(en.AEntity)); }
public static bool IsOwner(this AscensionEntity entity) { return(entity.IsAttached() && entity.IsOwner); }