8 Dictionary<ModLoader, Action>
Hooks = [];
127 "OnChaseBehaviorStartChasing",
129 loader.OnChaseBehaviorStartChasing(
this);
145 "OnChaseBehaviorStopChasing",
147 loader.OnChaseBehaviorStopChasing(
this);
160 m_componentCreature.ComponentCreatureModel.LookAtOrder =
m_target.ComponentCreatureModel.EyePosition;
162 m_componentCreatureModel.AttackOrder =
true;
166 if (hitBody !=
null) {
170 bool bodyToHit =
true;
171 bool playAttackSound =
true;
173 "OnChaseBehaviorAttacked",
175 loader.OnChaseBehaviorAttacked(
this, chaseTimeBefore, ref
m_chaseTime, ref bodyToHit, ref playAttackSound);
182 if (playAttackSound) {
188 "OnChaseBehaviorAttackFailed",
190 loader.OnChaseBehaviorAttackFailed(
this, ref
m_chaseTime);
219 m_dayChaseTime = valuesDictionary.GetValue<
float>(
"DayChaseTime");
225 m_componentCreature.ComponentBody.CollidedWithBody += delegate(
ComponentBody body) {
230 if (componentCreature2 !=
null) {
243 m_componentCreature.ComponentLocomotion.JumpOrder = 1f;
246 m_componentCreature.ComponentHealth.Injured += delegate(
Injury injury) {
251 bool chasePersistent =
false;
255 chasePersistent =
true;
265 Attack(attacker, chaseRange, chaseTime, chasePersistent);
286 if (componentCreature !=
null) {
293 bool flag = m_subsystemSky.SkyLightIntensity >= 0.1f;
296 Attack(componentCreature, maxRange, maxChaseTime, !flag);
300 "UpdateChaseBehaviorLookingForTarget",
302 loader.UpdateChaseBehaviorLookingForTarget(
this);
355 else if (
m_target.ComponentHealth.Health <= 0f) {
360 if (m_target != null) {
361 m_componentFeedBehavior.Feed(m_target.ComponentBody.Position);
370 m_importanceLevel = 0f;
373 m_stateMachine.TransitionTo(
"RandomMoving");
376 if (ScoreTarget(m_target) <= 0f) {
377 m_targetUnsuitableTime += m_dt;
380 m_targetUnsuitableTime = 0f;
386 int maxPathfindingPositions = 0;
388 maxPathfindingPositions = m_subsystemTime.FixedTimeStep.HasValue ? 2000 : 500;
392 Vector3 v = 0.5f * (boundingBox.Min + boundingBox.
Max);
393 Vector3 vector = 0.5f * (boundingBox2.Min + boundingBox2.
Max);
395 float num2 = num < 4f ? 0.2f : 0f;
397 vector + num2 * num *
m_target.ComponentBody.Velocity,
400 maxPathfindingPositions,
412 "UpdateChaseBehaviorChasing",
414 loader.UpdateChaseBehaviorChasing(
this);
432 if (componentCreature !=
null) {
436 result = componentCreature;
448 bool notHarmless = componentCreature ==
Target || m_subsystemGameInfo.WorldSettings.GameMode >
GameMode.Harmless;
449 bool isAutoChaseMask = (componentCreature.Category &
m_autoChaseMask) != 0;
450 bool allowToChaseNonCreature = componentCreature ==
Target
454 + GetHashCode() % 1000 / 1000f
455 + componentCreature.GetHashCode() % 1000 / 1000f,
460 && ((!isPlayer && allowToChaseNonCreature) || (isPlayer && notHarmless))
470 "ChaseBehaviorScoreTarget",
472 loader.ChaseBehaviorScoreTarget(
this, componentCreature, ref score);
501 Vector3 v = 0.5f * (boundingBox.Min + boundingBox.
Max);
502 Vector3 v2 = 0.5f * (boundingBox2.Min + boundingBox2.
Max) - v;
505 float num2 = 0.5f * (boundingBox.Max.X - boundingBox.Min.X + boundingBox2.Max.X - boundingBox2.
Min.
X);
506 float num3 = 0.5f * (boundingBox.Max.Y - boundingBox.Min.Y + boundingBox2.Max.Y - boundingBox2.
Min.
Y);
507 if (MathF.Abs(v2.
Y) < num3 * 0.99f) {
508 if (num < num2 + 0.99f
513 else if (num < num3 + 0.3f
533 Vector3 v = 0.5f * (boundingBox.Min + boundingBox.
Max);
534 Vector3 v2 = 0.5f * (boundingBox2.Min + boundingBox2.
Max) - v;
537 float num2 = 0.5f * (boundingBox.Max.X - boundingBox.Min.X + boundingBox2.Max.X - boundingBox2.
Min.
X);
538 float num3 = 0.5f * (boundingBox.Max.Y - boundingBox.Min.Y + boundingBox2.Max.Y - boundingBox2.
Min.
Y);
539 if (MathF.Abs(v2.
Y) < num3 * 0.99f) {
540 if (num < num2 + 0.99f
545 else if (num < num3 + 0.3f
557 if (bodyRaycastResult.HasValue
563 hitPoint = bodyRaycastResult.Value.
HitPoint();
static float Remainder(float x, float y)
static int Min(int x1, int x2)
static int Max(int x1, int x2)
virtual ComponentBody ParentBody
virtual BoundingBox BoundingBox
virtual ComponentBody StandingOnBody
virtual float ImmersionDepth
virtual bool IsChildOfBody(ComponentBody componentBody)
float m_targetUnsuitableTime
float m_chaseNonPlayerProbability
virtual float ScoreTarget(ComponentCreature componentCreature)
ComponentPathfinding m_componentPathfinding
DynamicArray< ComponentBody > m_componentBodies
float? ChaseTimeOnAttacked
float ImportanceLevelNonPersistent
float? ChaseRangeOnAttacked
virtual void StopAttack()
virtual bool IsTargetInAttackRange(ComponentBody target)
virtual bool IsBodyInAttackRange(ComponentBody target)
virtual ComponentCreature FindTarget()
bool AttacksNonPlayerCreature
ComponentMiner m_componentMiner
SubsystemBodies m_subsystemBodies
float TargetInRangeTimeToChase
ComponentCreature m_target
float ImportanceLevelPersistent
ComponentFactors m_componentFactors
ComponentRandomFeedBehavior m_componentFeedBehavior
ComponentCreatureModel m_componentCreatureModel
CreatureCategory m_autoChaseMask
virtual void Attack(ComponentCreature componentCreature, float maxRange, float maxChaseTime, bool isPersistent)
SubsystemPlayers m_subsystemPlayers
bool PlayIdleSoundWhenStartToChase
bool JumpWhenTargetStanding
virtual ComponentBody GetHitBody(ComponentBody target, out Vector3 hitPoint)
ComponentCreature m_componentCreature
bool? ChasePersistentOnAttacked
override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
float m_chaseOnTouchProbability
bool PlayAngrySoundWhenChasing
virtual void Update(float dt)
SubsystemNoise m_subsystemNoise
float m_chaseWhenAttackedProbability
SubsystemGameInfo m_subsystemGameInfo
float m_autoChaseSuppressionTime
StateMachine m_stateMachine
override float ImportanceLevel
Dictionary< ModLoader, Action > Hooks
float MinHealthToAttackActively
float m_targetInRangeTime
SubsystemSky m_subsystemSky
SubsystemTime m_subsystemTime
virtual bool IsTargetInWater(ComponentBody target)
bool AllowAttackingStandingOnBody
ComponentHealth ComponentHealth
ComponentBody ComponentBody
virtual ComponentCreature Attacker
void TransitionTo(string stateName)
ValuesDictionary ValuesDictionary
Component FindComponent(Type type, string name, bool throwOnError)
static void HookAction(string HookName, Func< ModLoader, bool > action)
执行Hook
static Vector3 Normalize(Vector3 v)
static float Distance(Vector3 v1, Vector3 v2)
static readonly Vector3 UnitY
static float Dot(Vector3 v1, Vector3 v2)
ComponentBody ComponentBody