public override bool IsActionComplete() { if (Action != null && Action.IsActive() == false) { return(true); } /* WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.E_IN_COMBAT_RANGE); * if (prop.GetBool() == true) * return true;*/ return(false); }
// Update is called once per frame void Update() { if (Owner.IsAlive == false) { RotattionDiff = 0; return; } //Profiler.BeginSample ("ComponentBody.Update() : Main part"); if (Owner.IsInCover && Owner.IsLeavingToCover == false) { FinalRotation.eulerAngles = new Vector3(0, Owner.BlackBoard.Cover.Transform.rotation.eulerAngles.y, 0); if (Time.deltaTime > Mathf.Epsilon) { Owner.Transform.rotation = Quaternion.Lerp(Owner.Transform.rotation, FinalRotation, RotationSpeed * Time.deltaTime * 5); } CheckEdges(); } else if (Owner.IsInKnockdown) { RotattionDiff = 0; if (Owner.IsProxy) { // Server changes the player rotation during knockdown, we have to follow it, not ignore it FinalRotation.eulerAngles = new Vector3(0, Owner.BlackBoard.Desires.Rotation.eulerAngles.y, 0); if (Time.deltaTime > Mathf.Epsilon) { Owner.Transform.rotation = Quaternion.Lerp(Owner.Transform.rotation, FinalRotation, RotationSpeed * Time.deltaTime); } } } else { if (ActionRotate == null && Owner.IsServer == false) { float diff = Owner.Transform.rotation.eulerAngles.y - Owner.BlackBoard.Desires.Rotation.eulerAngles.y; if (diff < 0.001f && diff > -0.001f) { //clamp small numbers otherwise RotationDiff is being incremented for a long time if Desire and Owner rotation is not EXACTLY the same! diff = 0; } if (diff > 180) { diff -= 360; } else if (diff < -180) { diff += 360; } if (diff == 0) { RotattionDiff = 0; } else { RotattionDiff += Mathf.Abs(diff); } if (RotattionDiff > 10) { ActionRotate = AgentActionFactory.Create(AgentActionFactory.E_Type.Rotate) as AgentActionRotate; ActionRotate.Rotation = diff > 0 ? E_RotationType.Left : E_RotationType.Right; Owner.BlackBoard.ActionAdd(ActionRotate); RotattionDiff = 0; } } FinalRotation.eulerAngles = new Vector3(0, Owner.BlackBoard.Desires.Rotation.eulerAngles.y, 0); //if( !Owner.IsProxy ) if (!Owner.IsServer) // rotation on server is driven by ServerUpdate() { if (Time.deltaTime > Mathf.Epsilon) { Owner.Transform.rotation = Quaternion.Lerp(Owner.Transform.rotation, FinalRotation, RotationSpeed * Time.deltaTime); //Owner.Transform.rotation = Owner.BlackBoard.Desires.Rotation; } } } //Profiler.EndSample(); //Profiler.BeginSample ("ComponentBody.Update() : UpdateAiming"); UpdateAiming(); //Profiler.EndSample(); if (ActionRotate != null && ActionRotate.IsActive() == false) { ActionRotate = null; } HandleMovement(); }