Exemplo n.º 1
0
        public void SpawnEntity()
        {
            if (SpawnedEntity)
            {
                return;
            }

            //check for warning conditions
            if (string.IsNullOrEmpty(FormID))
            {
                Debug.LogError($"EntityPlaceholder on {gameObject.name}: No entity defined!");
                return;
            }

            if (string.IsNullOrEmpty(ThingID) && UsePlaceholderTID && !DestroyPlaceholder)
            {
                Debug.LogWarning($"EntityPlaceholder on {gameObject.name}: No TID given, and set to use placeholder TID without destroying placeholder (will result in objects with same TID!)");
            }

            string tid = string.IsNullOrEmpty(ThingID) ? (UsePlaceholderTID ? gameObject.name : null) : ThingID;

            try
            {
                //this looks like archaic C style error checking
                if (WorldUtils.SpawnEntity(FormID, tid, transform.position, transform.eulerAngles, transform.parent) == null)
                {
                    Debug.LogError($"EntityPlaceholder on {gameObject.name}: Failed to spawn entity (unknown)");
                }
            }
            catch (Exception e)
            {
                Debug.LogError($"EntityPlaceholder on {gameObject.name}: Failed to spawn entity ({e.GetType().Name})");
                if (ConfigState.Instance.UseVerboseLogging)
                {
                    Debug.LogException(e);
                }
            }

            SpawnedEntity = true;

            if (DestroyPlaceholder)
            {
                Destroy(this.gameObject);
            }
        }
Exemplo n.º 2
0
 static void Spawn(string fid)
 {
     WorldUtils.SpawnEntity(fid, null, (WorldUtils.GetPlayerObject().transform.position + (WorldUtils.GetPlayerObject().transform.forward * 1.0f)), Vector3.zero, null);
 }