Ejemplo n.º 1
0
        public void CopyFrom(object target)
        {
            var right = target as LatestAdjustCmdComponent;

            AdjustPos = right.AdjustPos;
            ServerSeq = right.ServerSeq;
        }
Ejemplo n.º 2
0
        public void CopyFrom(object rightComponent)
        {
            var r = rightComponent as FreeMoveController;

            FocusOnPosition = r.FocusOnPosition;
            ControllType    = r.ControllType;
        }
        public override void DoHandle(int messageType, PlayerDamageInfoMessage messageBody)
        {
            Logger.DebugFormat("Handle message {0} {1} {2} {3}", messageBody.EntityId, messageBody.Damage, messageBody.PosX, messageBody.PosZ);
            var selfPlayer = _playerContext.flagSelfEntity;

            if (null == selfPlayer)
            {
                Logger.Error("self player is null");
                return;
            }
            if (!selfPlayer.hasCameraObj)
            {
                Logger.Error("player has no camera obj");
                return;
            }
            if (!selfPlayer.hasPosition)
            {
                Logger.Error("player has no position");
                return;
            }
            var forword   = selfPlayer.cameraObj.MainCamera.transform.forward;
            var forwordxz = new Vector2(forword.x, forword.z);
            var myPos     = selfPlayer.position.Value;
//            var damageSrcPos = new Vector3(messageBody.PosX, 0, messageBody.PosZ);
            var damageSrcPos = new FixedVector3(messageBody.PosX, 0, messageBody.PosZ);
            var dir          = damageSrcPos.ShiftedVector3() - myPos;
            var dirxz        = new Vector2(dir.x, dir.z);
            var cross        = dirxz.x * forwordxz.y - dirxz.y * forwordxz.x;
            var angle        = Vector2.Angle(dirxz, forwordxz) * -Mathf.Sign(cross);

            Logger.InfoFormat("myPos {0} srcPos {1} camForward {2} Angle is {3}", myPos, damageSrcPos, forword, angle);
            _uiContext.uI.HurtedDataList[messageBody.EntityId] = new CrossHairHurtedData(messageBody.Damage, angle, new Vector2(damageSrcPos.ShiftedVector3().x, damageSrcPos.ShiftedVector3().z));
        }
Ejemplo n.º 4
0
        public virtual void ReadBody(BinaryReader reader)
        {
//            footstepState = (AudioGrp_Footstep) FieldSerializeUtil.Deserialize((byte) 0, reader);
//            footMatType   = (AudioGrp_FootMatType) FieldSerializeUtil.Deserialize((byte) 0, reader);
            relatedPos      = FieldSerializeUtil.Deserialize(relatedPos, reader);
            relatedRocation = FieldSerializeUtil.Deserialize(relatedRocation, reader);
        }
Ejemplo n.º 5
0
        public virtual void Interpolate(object left, object right, IInterpolationInfo interpolationInfo)
        {
            var l = (VehicleDynamicDataComponent)left;
            var r = (VehicleDynamicDataComponent)right;

            if (IsSyncLatest)
            {
                return;
            }

            Flag = (int)VehicleFlag.RemoteSet;
            var rotio = interpolationInfo.Ratio;

            IsAccelerated = l.IsAccelerated && r.IsAccelerated;
            SteerInput    = InterpolateUtility.Interpolate(l.SteerInput, r.SteerInput, rotio);
            ThrottleInput = InterpolateUtility.Interpolate(l.ThrottleInput, r.ThrottleInput, rotio);

            Position = InterpolateUtility.Interpolate(l.Position, r.Position, rotio);
            Rotation = InterpolateUtility.Interpolate(l.Rotation, r.Rotation, rotio);

            LinearVelocity  = InterpolateUtility.Interpolate(l.LinearVelocity, r.LinearVelocity, rotio);
            AngularVelocity = InterpolateUtility.Interpolate(l.AngularVelocity, r.AngularVelocity, rotio);

            IsSleeping = l.IsSleeping;
        }
Ejemplo n.º 6
0
 public static FixedVector3 Interpolate(FixedVector3 l, FixedVector3 r, float ratio)
 {
     return(new FixedVector3(
                l.x + (r.x - l.x) * ratio,
                l.y + (r.y - l.y) * ratio,
                l.z + (r.z - l.z) * ratio));
 }
Ejemplo n.º 7
0
        public Storage.Box SaveToStorage()
        {
            FixedVector3 newPointOne = FixedVector3.Min(pointOne, pointTwo);
            FixedVector3 newPointTwo = FixedVector3.Max(pointOne, pointTwo);

            return(new Storage.Box(newPointOne, newPointTwo));
        }
Ejemplo n.º 8
0
        public void CopyFrom(object rightComponent)
        {
            var r = rightComponent as ObserveCameraComponent;

            CameraPosition   = r.CameraPosition;
            CameraEularAngle = r.CameraEularAngle;
            Fov = r.Fov;
        }
Ejemplo n.º 9
0
        public void Interpolate(object left, object right, IInterpolationInfo interpolationInfo)
        {
            var l = left as FreeMoveController;
            var r = right as FreeMoveController;

            FocusOnPosition = InterpolateUtility.Interpolate(l.FocusOnPosition, r.FocusOnPosition, interpolationInfo);
            ControllType    = r.ControllType;
        }
Ejemplo n.º 10
0
        public static bool IsApproximatelyEqual(FixedVector3 left, FixedVector3 right, float maxError = 0.01f)
        {
            FixedVector3 l = left;
            FixedVector3 r = right;

            return(IsApproximatelyEqual(l.x, r.x) && IsApproximatelyEqual(l.y, r.y) &&
                   IsApproximatelyEqual(l.z, r.z));
        }
Ejemplo n.º 11
0
        public static FixedVector3 Interpolate(FixedVector3 l, FixedVector3 r, IInterpolationInfo interpolationInfo)
        {
            var ratio = interpolationInfo.Ratio;

            return(new FixedVector3(
                       l.x + (r.x - l.x) * ratio,
                       l.y + (r.y - l.y) * ratio,
                       l.z + (r.z - l.z) * ratio));
        }
Ejemplo n.º 12
0
        public void CopyFrom(object rightComponent)
        {
            var right = rightComponent as FirePosition;

            SightValid       = right.SightValid;
            SightPosition    = right.SightPosition;
            MuzzleP3Valid    = right.MuzzleP3Valid;
            MuzzleP3Position = right.MuzzleP3Position;
        }
Ejemplo n.º 13
0
        public void ReadBody(BinaryReader reader)
        {
            Target = FieldSerializeUtil.Deserialize(Target, reader);
            Offset = FieldSerializeUtil.Deserialize(Offset, reader);

            HitPoint    = FieldSerializeUtil.Deserialize(HitPoint, reader);
            HitAudioId  = FieldSerializeUtil.Deserialize(HitAudioId, reader);
            HitBodyPart = FieldSerializeUtil.Deserialize(HitBodyPart, reader);
        }
Ejemplo n.º 14
0
 public void SyncFrom(PlayerSkyMoveComponent r)
 {
     ParachuteTime         = r.ParachuteTime;
     Position              = r.Position;
     Rotation              = r.Rotation;
     SwingVelocity         = r.SwingVelocity;
     ExtraVerticalVelocity = r.ExtraVerticalVelocity;
     Velocity              = r.Velocity;
 }
Ejemplo n.º 15
0
 public void ReadBody(BinaryReader reader)
 {
     Offset           = FieldSerializeUtil.Deserialize(Offset, reader);
     HitPoint         = FieldSerializeUtil.Deserialize(HitPoint, reader);
     EnvironmentType  = (EEnvironmentType)FieldSerializeUtil.Deserialize((byte)0, reader);
     HitAudioId       = FieldSerializeUtil.Deserialize(HitAudioId, reader);
     needEffectEntity = FieldSerializeUtil.Deserialize((byte)0, reader) == 1;
     ChunkId          = FieldSerializeUtil.Deserialize(ChunkId, reader);
 }
Ejemplo n.º 16
0
        public FixedVector3 RotateYAxe(Fixed sin, Fixed cos, FixedVector3 pivotPoint)
        {
            Fixed nx = (x - pivotPoint.x) * cos + (z - pivotPoint.z) * sin + pivotPoint.x;
            Fixed nz = (z - pivotPoint.z) * cos - (x - pivotPoint.x) * sin + pivotPoint.z;

            x = nx;
            z = nz;
            return(this);
        }
Ejemplo n.º 17
0
        public FixedVector3 RotateXAxe(Fixed sin, Fixed cos, FixedVector3 pivotPoint)
        {
            Fixed ny = (y - pivotPoint.y) * cos - (z - pivotPoint.z) * sin + pivotPoint.y;
            Fixed nz = (y - pivotPoint.y) * sin + (z - pivotPoint.z) * cos + pivotPoint.z;

            y = ny;
            z = nz;
            return(this);
        }
Ejemplo n.º 18
0
        public FixedVector3 RotateZAxe(Fixed sin, Fixed cos, FixedVector3 pivotPoint)
        {
            Fixed nx = (x - pivotPoint.x) * cos - (y - pivotPoint.y) * sin + pivotPoint.x;
            Fixed ny = (x - pivotPoint.x) * sin + (y - pivotPoint.y) * cos + pivotPoint.y;

            x = nx;
            y = ny;
            return(this);
        }
Ejemplo n.º 19
0
        public void CopyFrom(object rightComponent)
        {
            var r = rightComponent as PlayerMoveByAnimUpdateComponent;

            Position   = r.Position;
            ModelPitch = r.ModelPitch;
            ModelYaw   = r.ModelYaw;
            NeedUpdate = r.NeedUpdate;
        }
Ejemplo n.º 20
0
        public void RewindTo(IEvent value)
        {
            HitPlayerEvent right = value as HitPlayerEvent;

            Target      = right.Target;
            Offset      = right.Offset;
            HitPoint    = right.HitPoint;
            HitAudioId  = right.HitAudioId;
            HitBodyPart = right.HitBodyPart;
        }
Ejemplo n.º 21
0
        public void Interpolate(object left, object right, IInterpolationInfo interpolationInfo)
        {
            var l = left as ObserveCameraComponent;
            var r = right as ObserveCameraComponent;

            Fov              = InterpolateUtility.Interpolate(l.Fov, r.Fov, interpolationInfo);
            CameraPosition   = InterpolateUtility.Interpolate(l.CameraPosition, r.CameraPosition, interpolationInfo);
            CameraEularAngle =
                InterpolateUtility.Interpolate(l.CameraEularAngle, r.CameraEularAngle, interpolationInfo);
        }
Ejemplo n.º 22
0
        public void RecalculateSurfaceEquation()
        {
            FixedVector3 v    = b.coordinates - a.coordinates;
            FixedVector3 u    = c.coordinates - a.coordinates;
            Fixed        detY = v.x * u.z - v.z * u.x;

            this.mX = (v.y * u.z - v.z * u.y) / detY;
            this.mZ = (v.x * u.y - v.y * u.x) / detY;
            this.mC = a.coordinates.y - a.coordinates.x * mX - a.coordinates.z * mZ;
        }
Ejemplo n.º 23
0
        public void RewindTo(IEvent value)
        {
            HitEnvironmentEvent right = value as HitEnvironmentEvent;

            Offset           = right.Offset;
            HitPoint         = right.HitPoint;
            HitAudioId       = right.HitAudioId;
            EnvironmentType  = right.EnvironmentType;
            needEffectEntity = right.needEffectEntity;
            ChunkId          = right.ChunkId;
        }
Ejemplo n.º 24
0
        public void CopyFrom(object rightComponent)
        {
            var r = rightComponent as PlayerSkyMoveInterVarComponent;

            ParachuteTime         = r.ParachuteTime;
            Position              = r.Position;
            Rotation              = r.Rotation;
            SwingVelocity         = r.SwingVelocity;
            ExtraVerticalVelocity = r.ExtraVerticalVelocity;

            Velocity = r.Velocity;
        }
Ejemplo n.º 25
0
        public static FixedVector3 Deserialize(FixedVector3 typeTag, float max, float min, float ratio, int receiveTimes, bool DoCompress,
                                               BinaryReader reader)
        {
            if (!DoCompress)
            {
                return(Deserialize(typeTag, reader));
            }
            float x = Deserialize(typeTag.x, max, min, ratio, receiveTimes, DoCompress, reader);
            float y = Deserialize(typeTag.y, max, min, ratio, receiveTimes, DoCompress, reader);
            float z = Deserialize(typeTag.z, max, min, ratio, receiveTimes, DoCompress, reader);

            return(new FixedVector3(x, y, z));
        }
Ejemplo n.º 26
0
        /// <summary>
        ///   <para>Returns true if the x and y components of point is a point inside this rectangle. If allowInverse is present and true, the width and height of the FixedRect are allowed to take negative values (ie, the min value is greater than the max), and the test will still work.</para>
        /// </summary>
        /// <param name="point">Point to test.</param>
        /// <param name="allowInverse">Does the test allow the FixedRect's width and height to be negative?</param>
        /// <returns>
        ///   <para>True if the point lies within the specified rectangle.</para>
        /// </returns>
        public bool Contains(FixedVector3 point, bool allowInverse)
        {
            if (!allowInverse)
            {
                return(this.Contains(point));
            }
            bool flag = false;

            if ((Fixed)this.width < 0.0 && (Fixed)point.x <= (Fixed)this.xMin && (Fixed)point.x > (Fixed)this.xMax || (Fixed)this.width >= 0.0 && (Fixed)point.x >= (Fixed)this.xMin && (Fixed)point.x < (Fixed)this.xMax)
            {
                flag = true;
            }
            return(flag && ((Fixed)this.height < 0.0 && (Fixed)point.y <= (Fixed)this.yMin && (Fixed)point.y > (Fixed)this.yMax || (Fixed)this.height >= 0.0 && (Fixed)point.y >= (Fixed)this.yMin && (Fixed)point.y < (Fixed)this.yMax));
        }
Ejemplo n.º 27
0
        public static void Serialize(FixedVector3 typeTag, float max, float min, float ratio,
                                     int sendTimes, bool DoCompress, MyBinaryWriter writer, FixedVector3 last = default(FixedVector3),
                                     bool weiteAll = false)
        {
            if (!DoCompress)
            {
                Serialize(typeTag, writer, last, weiteAll);
                return;
            }

            Serialize(typeTag.x, max, min, ratio, sendTimes, DoCompress, writer, last.x, weiteAll);
            Serialize(typeTag.y, max, min, ratio, sendTimes, DoCompress, writer, last.y, weiteAll);
            Serialize(typeTag.z, max, min, ratio, sendTimes, DoCompress, writer, last.z, weiteAll);
        }
Ejemplo n.º 28
0
        public void CopyFrom(object rightComponent)
        {
            var r = rightComponent as SkyMoveUpdateComponent;

            IsMoveEnabled          = r.IsMoveEnabled;
            SkyMoveStage           = r.SkyMoveStage;
            SkyPosition            = r.SkyPosition;
            SkyRotation            = r.SkyRotation;
            SkyLocalPlayerPosition = r.SkyLocalPlayerPosition;
            SkyLocalPlayerRotation = r.SkyLocalPlayerRotation;
            Pitch     = r.Pitch;
            Yaw       = r.Yaw;
            Roll      = r.Roll;
            GameState = r.GameState;
        }
Ejemplo n.º 29
0
        public void CopyFrom(object rightComponent)
        {
            var r = rightComponent as PlayerSkyMoveComponent;

            IsMoving      = r.IsMoving;
            IsMoveEnabled = r.IsMoveEnabled;
            MoveStage     = r.MoveStage;

            Position = r.Position;
            Rotation = r.Rotation;

            LocalPlayerPosition = r.LocalPlayerPosition;
            LocalPlayerRotation = r.LocalPlayerRotation;

            GameState = r.GameState;
            Velocity  = r.Velocity;
        }
Ejemplo n.º 30
0
        public virtual void CopyFrom(object rightComponent)
        {
            var data = rightComponent as VehicleDynamicDataComponent;

            Flag = (int)VehicleFlag.RemoteSet;

            IsAccelerated = data.IsAccelerated;
            SteerInput    = data.SteerInput;
            ThrottleInput = data.ThrottleInput;

            Position        = data.Position;
            Rotation        = data.Rotation;
            LinearVelocity  = data.LinearVelocity;
            AngularVelocity = data.AngularVelocity;

            IsSleeping = data.IsSleeping;
        }