/// <summary> /// Draws the length of the behaviour custom. /// </summary> /// <returns>The behaviour custom length.</returns> /// <param name="_rule">Rule.</param> private static void DrawBehaviourCustomLength(ICECreatureControl _control, BehaviourModeRuleObject _rule, EditorHeaderType _type, string _help = "", string _title = "", string _hint = "") { if (_rule == null) { return; } if (string.IsNullOrEmpty(_title)) { _title = "Rule Length"; } if (string.IsNullOrEmpty(_hint)) { _hint = ""; } if (string.IsNullOrEmpty(_help)) { _help = Info.BEHAVIOUR_LENGTH; } ICEEditorLayout.BeginHorizontal(); CreatureObjectEditor.DrawObjectHeaderLine(ref _rule.UseCustomLength, ref _rule.FoldoutCustomLength, _type, _title, _hint); ICEEditorLayout.EndHorizontal(_help); if (_rule.UseCustomLength && _rule.FoldoutCustomLength) { EditorGUI.indentLevel++; ICEEditorLayout.BeginHorizontal(); ICEEditorLayout.MinMaxSlider("Min/Max Length (secs.)", "Enter the desired Play-Length or press 'RND' to set randomized values.", ref _rule.LengthMin, ref _rule.LengthMax, 0, ref _rule.LengthMaximum, 0.25f, 35); if (ICEEditorLayout.RandomButton("")) { _rule.LengthMax = Random.Range(_rule.LengthMin, _rule.LengthMaximum); _rule.LengthMin = Random.Range(0, _rule.LengthMax); } if (ICEEditorLayout.ButtonSmall("ANIM", "")) { _rule.LengthMin = _rule.Animation.GetAnimationLength(); _rule.LengthMax = _rule.LengthMin; } if (ICEEditorLayout.ResetButtonSmall("")) { _rule.LengthMin = 0; _rule.LengthMax = 0; } ICEEditorLayout.EndHorizontal(Info.BEHAVIOUR_LENGTH); EditorGUI.indentLevel--; EditorGUILayout.Separator(); } }
public virtual void DoBehaviourModeRuleChanged(GameObject _sender, BehaviourModeRuleObject _new_rule, BehaviourModeRuleObject _last_rule) { if (DebugLogIsEnabled) { if (_new_rule != null) { PrintDebugLog("DoBehaviourModeRuleChanged - '" + Creature.Behaviour.ActiveBehaviourModeKey + "' changed rule " + (_last_rule != null ? _last_rule.Index + " to rule " : "") + _new_rule.Index); } else { PrintDebugLog("DoBehaviourModeRuleChanged - '" + Creature.Behaviour.ActiveBehaviourModeKey + "' has empty rule!"); } } if (OnBehaviourModeRuleChanged != null) { OnBehaviourModeRuleChanged(_sender, _new_rule, _last_rule); } }
public static void Print(ICECreatureControl _control) { if (!_control.ShowInfo) { return; } string _info = "\n"; _info += "Status: \n"; _info += "\tAge\t\t\t : " + (_control.Creature.Status.UseAging ? DateTools.FormatTimeDetailed(_control.Creature.Status.Age) : "INACTIVE") + "\n"; _info += "\tGender\t\t\t : " + _control.Creature.Status.GenderType.ToString() + "\n"; _info += "\tTrophic Level\t\t : " + _control.Creature.Status.TrophicLevel.ToString() + "\n"; _info += "\tEnvironment Temperature\t : " + (_control.Creature.Status.UseEnvironmentTemperature ? _control.Creature.Status.TemperatureDeviationInPercent + "%" : "INACTIVE") + "\n"; _info += "\n"; if (_control.Creature.Status.UseAdvanced) { _info += "\tDurability\t\t : " + _control.Creature.Status.Durability + "/" + _control.Creature.Status.InitialDurabilityMaximum + " (" + _control.Creature.Status.DurabilityInPercent + "%) \n"; _info += "\n"; _info += "\tFitness\t\t\t : " + _control.Creature.Status.FitnessInPercent + "% \n"; _info += "\t\tHealth\t\t : " + _control.Creature.Status.HealthInPercent + "% \n"; _info += "\t\tPower\t\t : " + _control.Creature.Status.PowerInPercent + "% \n"; _info += "\t\tStamina\t\t : " + _control.Creature.Status.StaminaInPercent + "% \n"; _info += "\n"; _info += "\tArmor\t\t\t : " + (_control.Creature.Status.UseArmor ? _control.Creature.Status.ArmorInPercent + "%" : "INACTIVE") + "\n"; _info += "\tDamage\t\t\t : " + _control.Creature.Status.DamageInPercent + "% \n"; _info += "\tStress\t\t\t : " + _control.Creature.Status.StressInPercent + "% \n"; _info += "\tDebility\t\t\t : " + _control.Creature.Status.DebilityInPercent + "% \n"; _info += "\tHunger\t\t\t : " + _control.Creature.Status.HungerInPercent + "% \n"; _info += "\tThirst\t\t\t : " + _control.Creature.Status.ThirstInPercent + "% \n"; _info += "\n"; _info += "\tAggressivity\t\t : " + _control.Creature.Status.AggressivityInPercent + "% \n"; _info += "\tExperience\t\t : " + _control.Creature.Status.ExperienceInPercent + "% \n"; _info += "\tNosiness\t\t\t : " + _control.Creature.Status.NosinessInPercent + "% \n"; _info += "\tAnxiety\t\t\t : " + _control.Creature.Status.AnxietyInPercent + "% \n"; } else { _info += "\tDurability\t\t : " + _control.Creature.Status.Durability + "/" + _control.Creature.Status.InitialDurabilityMaximum + " (" + _control.Creature.Status.DurabilityInPercent + "%) \n"; _info += "\n"; _info += "\tFitness\t\t\t : " + _control.Creature.Status.FitnessInPercent + "% \n"; _info += "\tHealth\t\t\t : " + _control.Creature.Status.HealthInPercent + "% \n"; _info += "\tDamage\t\t\t : " + _control.Creature.Status.DamageInPercent + "% \n"; } _info += "\n"; _info += "Motion Control: " + _control.Creature.Move.MotionControl.ToString(); if (_control.Creature.Move.MotionControl == MotionControlType.RIGIDBODY) { Rigidbody _rb = _control.GetComponent <Rigidbody>(); if (_rb == null) { _info += " - MISSING RIGIDBODY"; } else { _info += "\n"; _info += "\tRigidbody Kinematic\t : " + _rb.isKinematic.ToString() + "\n"; _info += "\tRigidbody Gravity \t : " + _rb.useGravity.ToString() + "\n"; _info += "\tRigidbody Constraints\t : " + _rb.constraints.ToString() + "\n"; } } _info += "\n"; _info += "\tVelocity\t\t\t : " + _control.Velocity + "\n"; _info += "\tForward Speed\t\t : " + _control.Creature.Move.MoveSpeed + "\n"; _info += "\tAngular Speed\t\t : " + System.Math.Round(_control.Creature.Move.MoveAngularSpeed, 2) + " (" + System.Math.Round(_control.Creature.Move.MoveAngularSpeedLimited, 2) + ")\n"; _info += "\tVertical Speed\t\t : " + System.Math.Round(_control.Creature.Move.VerticalSpeed, 2) + "\n"; _info += "\tMove Direction\t\t : " + System.Math.Round(_control.Creature.Move.MoveDirectionAngle, 2) + "\n"; _info += "\tMove Distance\t\t : " + System.Math.Round(_control.Creature.Move.TargetMovePositionDistance, 2) + " (" + System.Math.Round(_control.Creature.Move.MovePositionDistance, 2) + ")\n"; _info += "\tAltitude\t\t\t : " + System.Math.Round(_control.Creature.Move.Altitude, 2) + " (" + System.Math.Round(_control.Creature.Move.AbsoluteAltitude, 2) + ")\n"; //+ " Behaviour Velocity : " + _control.Creature.Move.CurrentMove.Motion.Velocity.ToString() + "/" + _control.Creature.Move.CurrentMove.Motion.AngularVelocity.y + "\n"; Animator _animator = _control.GetComponent <Animator>(); if (_animator != null) { _info += "\n"; _info += "Animator\n"; _info += "\tController\t : " + (_animator.runtimeAnimatorController == null ? "missing" : _animator.runtimeAnimatorController.name) + "\n"; _info += "\tRootMotion\t : " + _animator.applyRootMotion.ToString() + "\n"; } _info += "\n"; _info += "Targets : " + GetTargetsCount(_control) + " (currently available: " + _control.Creature.AvailableTargets.Count + ")\n"; _info += "\tActive Target\t : '" + _control.Creature.ActiveTargetName + "' (" + _control.Creature.ActiveTargetID + ")\n"; _info += "\t\tRuntime\t : " + System.Math.Round(_control.Creature.ActiveTargetActiveTime, 3) + " secs. (total : " + System.Math.Round(_control.Creature.ActiveTargetActiveTimeTotal, 3) + " secs.)\n"; _info += "\t\tSpeed\t : " + System.Math.Round(_control.Creature.ActiveTargetSpeed, 3) + "\n"; _info += "\t\tVelocity\t : " + _control.Creature.ActiveTargetVelocity + "\n"; _info += "\t\tDistance\t : " + System.Math.Round(_control.Creature.ActiveTargetDistance, 3) + "\n"; _info += "\t\tDirection\t : " + _control.Creature.ActiveTargetDirection + "\n"; _info += "\t\tPosition\t : " + _control.Creature.ActiveTargetTransformPosition + "\n"; _info += "\n"; _info += "\tPrevious Target : '" + _control.Creature.PreviousTargetID + "' (" + _control.Creature.PreviousTargetName + ")\n\n"; _info += "Behaviours : " + _control.Creature.Behaviour.BehaviourModes.Count + " Modes with " + GetBehaviorModeRulesCount(_control) + " Rules \n"; _info += "\tActive Mode\t : '" + _control.Creature.Behaviour.ActiveBehaviourModeKey + "'\n"; _info += "\t\tRuntime\t : " + System.Math.Round(_control.Creature.Behaviour.BehaviourTimer, 3) + " secs.\n"; _info += "\tPrevious Mode\t : '" + _control.Creature.Behaviour.LastBehaviourModeKey + "'\n\n"; BehaviourModeRuleObject _rule = _control.Creature.Behaviour.ActiveBehaviourModeRule; if (_rule != null) { _info += "Animation Name : " + _rule.Animation.GetAnimationName() + " (" + _rule.Animation.GetAnimationLength() + " secs.)\n\n"; } else { } _info += "Current Move: " + _control.Creature.Move.CurrentMove.Enabled.ToString().ToUpper() + " type: " + _control.Creature.Move.CurrentMove.Type.ToString() + "\n"; _info += "\tStopping Distance: " + _control.Creature.Move.CurrentMove.StoppingDistance + " (default: " + _control.Creature.Move.DefaultMove.StoppingDistance + ")\n"; _info += "\t\tIgnore Level Difference: " + _control.Creature.Move.CurrentMove.IgnoreLevelDifference.ToString().ToUpper() + " (default: " + _control.Creature.Move.DefaultMove.IgnoreLevelDifference.ToString().ToUpper() + ")\n"; _info += "\tSegment Length: " + _control.Creature.Move.CurrentMove.SegmentLength + " (default: " + _control.Creature.Move.DefaultMove.SegmentLength + ")\n"; _info += "\t\tSegment Variance: " + _control.Creature.Move.CurrentMove.SegmentVariance + " (default: " + _control.Creature.Move.DefaultMove.SegmentVariance + ")\n"; _info += "\tDeviation Length: " + _control.Creature.Move.CurrentMove.DeviationLength + " (default: " + _control.Creature.Move.DefaultMove.DeviationLength + ")\n"; _info += "\t\tDeviation Variance: " + _control.Creature.Move.CurrentMove.DeviationVariance + " (default: " + _control.Creature.Move.DefaultMove.DeviationVariance + ")\n\n"; if (_control.Creature.Move.Deadlock.Enabled) { _info += "Deadlocked: " + (_control.Creature.Move.Deadlock.Deadlocked?"TRUE":"FALSE") + " (distance: " + _control.Creature.Move.Deadlock.DeadlocksDistance + " time: " + _control.Creature.Move.Deadlock.DeadlockMoveTimer + "/" + _control.Creature.Move.Deadlock.DeadlockLoopTimer + " secs.)\n"; _info += " deadlocks: " + _control.Creature.Move.Deadlock.DeadlocksCount + " - critical positions: " + _control.Creature.Move.Deadlock.DeadlocksCriticalPositions; _info += " loops: " + _control.Creature.Move.Deadlock.DeadlockLoopsCount + " - critical loops: " + _control.Creature.Move.Deadlock.DeadlocksCriticalLoops; } else { _info += "Deadlock Handling: deactivated"; } _info += "\n"; //_info += "Active Behaviour Rule : '" + _control.Creature.Behaviour.c + "'"; _info += "Active Counterparts: " + _control.ActiveCounterparts.Count + "\n"; foreach (ICECreatureEntity _entity in _control.ActiveCounterparts) { _info += "\t - " + _entity.name + " (" + _entity.ObjectInstanceID + ")\n"; } Info.Note(_info); }
/// <summary> /// Draws the behaviour mode rule. /// </summary> /// <param name="_index">_index.</param> /// <param name="_list">_list.</param> public static void DrawBehaviourModeRule(ICECreatureControl _control, BehaviourModeObject _mode, int _index, List <BehaviourModeRuleObject> _list, string _key) { BehaviourModeRuleObject _rule = _list[_index]; if (_rule == null) { return; } if (_list.Count > 1) { EditorGUI.indentLevel++; ICEEditorStyle.SplitterByIndent(EditorGUI.indentLevel); ICEEditorLayout.BeginHorizontal(); EditorGUI.BeginDisabledGroup(_rule.Enabled == false); _rule.Foldout = EditorGUILayout.Foldout(_rule.Foldout, _key + " Rule #" + (_index + 1), ICEEditorStyle.Foldout); EditorGUI.EndDisabledGroup(); GUILayout.FlexibleSpace(); ICEEditorLayout.StatusButton("ACTIVE", _rule.Active == false, Color.green); if (ICEEditorLayout.CopyButtonMiddle()) { _list.Add(new BehaviourModeRuleObject(_rule)); } GUILayout.Space(5); if (ICEEditorLayout.ListDeleteButton <BehaviourModeRuleObject>(_list, _rule, "Removes this rule.")) { return; } if (ICEEditorLayout.ListUpDownButtons <BehaviourModeRuleObject>(_list, _list.IndexOf(_rule))) { return; } _rule.Enabled = ICEEditorLayout.EnableButton("Enables/disables this rule", _rule.Enabled); ICEEditorLayout.EndHorizontal(Info.BEHAVIOUR_MODE_RULE); } else { _rule.Foldout = true; _rule.Enabled = true; } if (_rule.Foldout) { EditorHeaderType _header = EditorHeaderType.FOLDOUT_ENABLED_BOLD; EditorHeaderType _sub_header = EditorHeaderType.FOLDOUT_ENABLED_BOLD; EditorGUI.BeginDisabledGroup(_rule.Enabled == false); // WEIGHTEDRANDOM BEGIN if (_list.Count > 1 && _mode.RulesOrderType == SequenceOrderType.WEIGHTEDRANDOM) { _rule.Weight = ICEEditorLayout.DefaultSlider("Weight", "Weight Value for WEIGHTEDRANDOM Sequence Type, relative to other rules weight value", _rule.Weight, Init.DECIMAL_PRECISION, 0, 100, 1, Info.BEHAVIOUR_MODE_RULE_WEIGHT); } // WEIGHTEDRANDOM END EditorGUI.indentLevel++; // CUSTOM LENGTH BEGIN if (_list.Count > 1 || _rule.Link.Enabled) { DrawBehaviourCustomLength(_control, _rule, _header); } // CUSTOM LENGTH END CreatureBehaviourEditor.DrawBehaviourAnimation(_control, _mode, _rule, _header); CreatureBehaviourEditor.DrawBehaviourMove(_control, _mode, _rule, _header); CreatureObjectEditor.DrawInfluenceObject(_mode, _rule.Influences, _header, _control.Creature.Status.UseAdvanced, _control.Creature.Status.InitialDurabilityMax, Info.BEHAVIOUR_INFLUENCES); CreatureObjectEditor.DrawInventoryActionObject(_control, _rule.Inventory, _header, Info.BEHAVIOUR_INVENTORY); CreatureObjectEditor.DrawAudioObject(_rule.Audio, _header, Info.BEHAVIOUR_AUDIO); CreatureObjectEditor.DrawEventsObject(_control, _rule.Events, _header, _sub_header, Info.BEHAVIOUR_EVENTS); CreatureObjectEditor.DrawLookDataObject(_rule.Look, _header, Info.BEHAVIOUR_LOOK); CreatureObjectEditor.DrawEffectObject(_control, _rule.Effect, _header, Info.BEHAVIOUR_EFFECT); CreatureBehaviourEditor.DrawBehaviourModeRuleLinkObject(_control, _list, _rule.Link, _header, Info.BEHAVIOUR_LINK, "", "", _key + "_" + _index); EditorGUILayout.Separator(); EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel--; } if (_list.Count > 1) { EditorGUI.indentLevel--; } }