/// <summary> /// Handles the debug. /// </summary> /// <returns>The debug.</returns> /// <param name="_entity">Entity.</param> /// <typeparam name="T">The 1st type parameter.</typeparam> public static T HandleDebug <T>(ICECreatureEntity _entity) where T : Behaviour { if (_entity == null) { return(null); } T _debug = _entity.GetComponent <T>(); if (_entity.UseDebug) { if (_debug == null) { _debug = _entity.gameObject.AddComponent <T>(); } else if (_debug.enabled == false) { _debug.enabled = true; } } else if (_debug != null) { _debug.enabled = false; } return(_debug); }
public override void OnTriggerEnter(Collider _collider) { if (IsRemoteClient) { return; } if (_collider == null) { return; } ICECreatureEntity _entity = _collider.gameObject.GetComponent <ICECreatureEntity>(); if (_entity != null) { if (DebugLogIsEnabled) { PrintDebugLog("OnTriggerEnter - " + _entity.name + " enter zone."); } ICECreatureZone _zone = _entity as ICECreatureZone; if (_zone != null) { EnterZone(_zone.name); } ICECreatureControl _creature = _entity as ICECreatureControl; if (_creature != null) { _creature.Creature.UpdateStatusInfluences(Influences); } } }
/// <summary> /// Gets the nearest focused entity by the specified type. /// </summary> /// <returns>The nearest focused entity by type.</returns> /// <param name="_type">Type.</param> /// <param name="_allow_child">If set to <c>true</c> allow child.</param> public ICECreatureEntity GetBestCounterpartByType(EntityClassType _type, int _max_counterparts, bool _allow_child = false) { ICECreatureEntity _best_entity = null; float _best_distance = Mathf.Infinity; int _best_counterparts = _max_counterparts; // transform buffer Transform _transform = this.transform; for (int i = 0; i < ActiveCounterparts.Count; i++) { ICECreatureEntity _entity = ActiveCounterparts[i]; if (_entity != null && _entity.EntityType == _type) { Transform _entity_transform = _entity.transform; int _entity_counterparts = _entity.ActiveCounterparts.Count; float _entity_distance = PositionTools.Distance(_transform.position, _entity_transform.position); if ((_entity_distance <= _best_distance) && (_allow_child || _entity_transform.IsChildOf(_transform) == false) && (_best_counterparts == -1 || _entity_counterparts <= _best_counterparts)) { _best_counterparts = _entity_counterparts; _best_distance = _entity_distance; _best_entity = _entity; } } } return(_best_entity); }
/// <summary> /// Gets the nearest focused entity. /// </summary> /// <returns>The nearest focused entity.</returns> /// <param name="_allow_child">If set to <c>true</c> allow child.</param> public ICECreatureEntity GetNearestActiveCounterparts(bool _allow_child = false) { ICECreatureEntity _best_entity = null; float _best_distance = Mathf.Infinity; // transform buffer Transform _transform = this.transform; for (int i = 0; i < ActiveCounterparts.Count; i++) { ICECreatureEntity _entity = ActiveCounterparts[i]; if (_entity != null) { // transform buffer Transform _entity_transform = _entity.transform; float _distance = PositionTools.Distance(_transform.position, _entity_transform.position); if (_distance < _best_distance) { if (_allow_child || _entity_transform.IsChildOf(_transform) == false) { _best_distance = _distance; _best_entity = _entity; } } } } return(_best_entity); }
protected virtual void DrawEntityContent(ICECreatureEntity _entity) { if (_entity == null) { return; } CreatureObjectEditor.DrawEntityStatusObject(_entity, _entity.Status, m_HeaderType); }
public void RemoveActiveCounterpart(ICECreatureEntity _entity) { if (_entity == null || ActiveCounterparts.Count == 0) { return; } ActiveCounterparts.Remove(_entity); //Debug.Log( this.name + " remove target " + _entity.name + " (" + _entity.ObjectInstanceID + ") Count: " + FocusedEntities.Count ); }
/* * private InventoryObject m_Inventory = null; * public InventoryObject EntityInventory{ * get{ * * * } * }*/ public void AddActiveCounterpart(ICECreatureEntity _entity) { if (_entity == null) { return; } if (!ActiveCounterpartExists(_entity)) { ActiveCounterparts.Add(_entity); } //Debug.Log( this.name + " add target " + _entity.name + " (" + _entity.ObjectInstanceID + ") Count: " + FocusedEntities.Count ); }
public bool ActiveCounterpartExists(ICECreatureEntity _entity) { if (_entity == null || _entity == this) { return(true); } if (ActiveCounterparts.IndexOf(_entity) > -1) { return(true); } return(false); }
/// <summary> /// Draws the footer. /// </summary> /// <param name="_target">Target.</param> public virtual void DrawFooter(ICECreatureEntity _entity) { if (_entity == null) { return; } EditorGUILayout.Separator(); CreatureObjectEditor.DrawEntityRuntimeBehaviourObject(_entity, _entity.RuntimeBehaviour, m_HeaderType); if (_entity as ICECreatureItem != null) { if (_entity.ObjectRigidbody == null || _entity.ObjectColliders == null) { EditorGUILayout.HelpBox(Info.RIGIDBODY_AND_COLLIDER, MessageType.Info); } ICEEditorLayout.DrawAddRigidbody(_entity.gameObject); ICEEditorLayout.DrawAddCollider(_entity.gameObject); EditorGUILayout.Separator(); } else if (_entity as ICECreatureBodyPart != null || _entity as ICECreatureZone != null) { if (_entity.ObjectColliders == null) { EditorGUILayout.HelpBox(Info.TRIGGER_COLLIDER, MessageType.Info); } ICEEditorLayout.DrawAddTrigger(_entity.gameObject); } ICECreatureEntityEditor.DrawTargetAttribute(_entity.gameObject); EditorGUILayout.Separator(); // indentLevel was increased in the header, so we have to decrease the level here EditorGUI.indentLevel--; // Version Info EditorGUILayout.LabelField(" - " + _entity.GetType().ToString() + " v" + Info.Version + " - ", EditorStyles.centeredGreyMiniLabel); MarkSceneDirty(_entity); }
protected override void DrawEntityContent(ICECreatureEntity _entity) { if (_entity == null) { return; } if (_entity.IsRootEntity || _entity.Status.IsDestructible || _entity.Status.UseLifespan) { string _text = "Please note, basically a body part should be a child within the transform hierarchy of an higher entity " + "and you should enable the damage transfer multiplier to forward incomming damages to the parent according to the" + "specified value, so you could disable and ignore Lifespan and Durability. But in some cases it could be also useful " + "to use Lifespan and Durability for body parts to force specific effects but please consider that destroying a body " + "part within a given transform hierarchy could result uncomely and unwanted effects, so please be careful what you do!"; EditorGUILayout.HelpBox(_text, MessageType.None); } CreatureObjectEditor.DrawEntityStatusObject(_entity, _entity.Status, m_HeaderType); }
/// <summary> /// Raises the inspector GUI event. /// </summary> public override void OnInspectorGUI() { ICECreatureEntity _target = DrawEntityHeader <ICECreatureEntity>(); DrawFooter(_target); }
/// <summary> /// Draws the entity settings. /// </summary> /// <param name="_entity">Entity.</param> public static void DrawEntitySettings(ICECreatureEntity _entity) { if (_entity == null) { return; } if (_entity.EntityType == ICE.World.EnumTypes.EntityClassType.Creature && Application.isPlaying) { EditorGUILayout.HelpBox(Info.DISPLAY_OPTIONS_RUNTIME_INFO, MessageType.Info); } EditorGUILayout.Separator(); if (ICECreatureRegister.Instance == null) { GUI.backgroundColor = Color.yellow; if (ICEEditorLayout.ButtonExtraLarge("ADD CREATURE REGISTER", Info.REGISTER_MISSING)) { ICECreatureRegister.Create(); } GUI.backgroundColor = ICEEditorLayout.DefaultBackgroundColor; } else if (!ICECreatureRegister.Instance.isActiveAndEnabled) { GUI.backgroundColor = Color.yellow; if (ICEEditorLayout.ButtonExtraLarge("ACTIVATE CREATURE REGISTER", Info.REGISTER_DISABLED)) { ICECreatureRegister.Instance.gameObject.SetActive(true); } GUI.backgroundColor = ICEEditorLayout.DefaultBackgroundColor; } else { Popups.QuickSelectionPopup("Quick Selection", _entity); } ICEEditorLayout.BeginHorizontal(); ICEEditorLayout.PrefixLabel("Debug Options"); GUILayout.FlexibleSpace(); _entity.UseDebugLogs = ICEEditorLayout.DebugButtonSmall("LOG", "Print debug information for this GameObject", _entity.UseDebugLogs); EditorGUI.BeginDisabledGroup(_entity.UseDebugLogs == false); if (_entity.UseDebugLogs) { _entity.UseDebugLogsSelectedOnly = ICEEditorLayout.DebugButtonMini("S", "Shows debug information for selected GameObjects only.", _entity.UseDebugLogsSelectedOnly); } else { ICEEditorLayout.DebugButtonMini("S", "Shows debug information for selected GameObjects only.", false); } EditorGUI.EndDisabledGroup(); GUILayout.Space(3); _entity.UseDebugRays = ICEEditorLayout.DebugButtonSmall("RAY", "Shows debug rays for this GameObject", _entity.UseDebugRays); EditorGUI.BeginDisabledGroup(_entity.UseDebugRays == false); if (_entity.UseDebugRays) { _entity.UseDebugRaysSelectedOnly = ICEEditorLayout.DebugButtonMini("S", "Shows debug rays for selected GameObjects only.", _entity.UseDebugRaysSelectedOnly); } else { ICEEditorLayout.DebugButtonMini("S", "Shows debug rays for selected GameObjects only.", false); } EditorGUI.EndDisabledGroup(); GUILayout.Space(3); _entity.UseDebug = ICEEditorLayout.DebugButton("DEBUG", "Enables enhanced debug options", _entity.UseDebug); GUILayout.Space(3); EditorGUI.BeginDisabledGroup(_entity as ICECreatureControl == null); _entity.ShowInfo = ICEEditorLayout.DebugButton("INFO", "Displays runtime information.", _entity.ShowInfo); EditorGUI.EndDisabledGroup(); _entity.ShowHelp = ICEEditorLayout.DebugButton("HELP", "Displays all help informations", _entity.ShowHelp); _entity.ShowNotes = ICEEditorLayout.DebugButton("NOTES", "Displays all note fields", _entity.ShowNotes); ICEEditorLayout.EndHorizontal(Info.ENTITY_DEBUG_OPTIONS); }
public bool CompareEntity(ICECreatureEntity _entity_1, ICECreatureEntity _entity_2) { return(_entity_1 == null || _entity_2 == null || _entity_1 == this || _entity_2 == this || _entity_1 != _entity_2 || _entity_1.ObjectInstanceID != _entity_2.ObjectInstanceID ? false : true); }