Exemplo n.º 1
0
        public override bool Write(Connection connection, NetworkObj obj, NetworkStorage storage, Packet packet)
        {
            if (obj.RootState.Entity.HasParent)
            {
                if (connection.entityChannel.ExistsOnRemote(obj.RootState.Entity.Parent))
                {
                    packet.WriteEntity(obj.RootState.Entity.Parent);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                packet.WriteEntity(null);
            }

            if (PositionEnabled)
            {
                PositionCompression.Pack(packet, storage.Values[obj[this] + POSITION].Vector3);

                if (Extrapolation.Enabled)
                {
                    PositionCompression.Pack(packet, storage.Values[obj[this] + VELOCITY].Vector3);
                }
            }

            if (RotationEnabled)
            {
                RotationCompression.Pack(packet, storage.Values[obj[this] + ROTATION].Quaternion);
            }

            return(true);
        }
Exemplo n.º 2
0
        public void BeginSmoothing()
        {
            SmoothStorageFrom = DuplicateStorage(Storage);
            SmoothStorageTo   = DuplicateStorage(Storage);

            SmoothFrameFrom = Core.Frame;
            SmoothFrameTo   = SmoothFrameFrom + Meta.SmoothFrames;
        }
Exemplo n.º 3
0
        public override object DebugValue(NetworkObj obj, NetworkStorage storage)
        {
            if (storage.Values[obj[this]].ProtocolToken == null)
            {
                return("NULL");
            }

            return(storage.Values[obj[this]].ProtocolToken.ToString());
        }
Exemplo n.º 4
0
        public void FreeStorage(NetworkStorage storage)
        {
            storage.Frame = 0;
            storage.Root  = null;
            storage.ClearAll();

            System.Array.Clear(storage.Values, 0, storage.Values.Length);

            StoragePool.Push(storage);
        }
Exemplo n.º 5
0
        public override bool Write(Connection connection, NetworkObj obj, NetworkStorage storage, Packet packet)
        {
            // adjust trigger
            storage.Values[obj[this]].TriggerSend.Update(Core.Frame, false);

            // write history
            packet.WriteInt(storage.Values[obj[this]].TriggerSend.History, obj.RootState.Entity.SendRate);

            // this always succeeds!
            return(true);
        }
Exemplo n.º 6
0
        public override object DebugValue(NetworkObj obj, NetworkStorage storage)
        {
            Entity entity = Core.FindEntity(storage.Values[obj[this]].NetworkId);

            if (entity)
            {
                return(entity.ToString());
            }

            return("NULL");
        }
Exemplo n.º 7
0
 public override void Read(Connection connection, NetworkObj obj, NetworkStorage storage, Packet packet)
 {
     if (Interpolation.Enabled)
     {
         storage.Values[obj[this] + 1].Float1 = Compression.Read(packet);
     }
     else
     {
         storage.Values[obj[this]].Float0 = Compression.Read(packet);
     }
 }
Exemplo n.º 8
0
        public NetworkStorage DuplicateStorage(NetworkStorage s)
        {
            NetworkStorage c;

            c       = AllocateStorage();
            c.Root  = s.Root;
            c.Frame = s.Frame;

            Array.Copy(s.Values, 0, c.Values, 0, s.Values.Length);

            return(c);
        }
Exemplo n.º 9
0
        public override void Read(Connection connection, NetworkObj obj, NetworkStorage storage, Packet packet)
        {
            UE.Vector3 v = Compression.Read(packet);

            if (Interpolation.Enabled && (obj.Root is NetworkState))
            {
                storage.Values[obj[this] + 1].Vector3 = v;
            }
            else
            {
                storage.Values[obj[this]].Vector3 = v;
            }
        }
Exemplo n.º 10
0
 public override bool Write(Connection connection, NetworkObj obj, NetworkStorage storage, Packet packet)
 {
     try
     {
         packet.WriteToken(storage.Values[obj[this]].ProtocolToken);
         return(true);
     }
     catch (Exception exn)
     {
         NetLog.Error("User code threw exception while serializing protocol token");
         NetLog.Exception(exn);
         return(false);
     }
 }
Exemplo n.º 11
0
        public override void Read(Connection connection, NetworkObj obj, NetworkStorage storage, Packet packet)
        {
            obj.RootState.Entity.SetParentInternal(packet.ReadEntity());

            if (PositionEnabled)
            {
                storage.Values[obj[this] + POSITION].Vector3 = PositionCompression.Read(packet);

                if (Extrapolation.Enabled)
                {
                    storage.Values[obj[this] + VELOCITY].Vector3 = PositionCompression.Read(packet);
                }
            }

            if (RotationEnabled)
            {
                storage.Values[obj[this] + ROTATION].Quaternion = RotationCompression.Read(packet);
            }
        }
Exemplo n.º 12
0
        public override void SmoothCommandCorrection(NetworkObj obj, NetworkStorage from, NetworkStorage to, NetworkStorage storage, float t)
        {
            if (Interpolation.Enabled)
            {
                var v0 = from.Values[obj[this]].Vector3;
                var v1 = to.Values[obj[this]].Vector3;
                var m  = (v1 - v0).sqrMagnitude;

                if (m < (Interpolation.SnapMagnitude * Interpolation.SnapMagnitude))
                {
                    storage.Values[obj[this]].Vector3 = UE.Vector3.Lerp(v0, v1, t);
                }
                else
                {
                    storage.Values[obj[this]].Vector3 = v1;
                }
            }
            else
            {
                storage.Values[obj[this]].Vector3 = to.Values[obj[this]].Vector3;
            }
        }
Exemplo n.º 13
0
        void MecanimPull(NetworkObj obj, NetworkStorage storage)
        {
            if (obj.RootState.Animator == null)
            {
                return;
            }

            if (obj.RootState.Animator.GetBool(PropertyName) && (obj.RootState.Animator.IsInTransition(MecanimLayer) == false))
            {
                // update send trigger
                storage.Values[obj[this]].TriggerSend.Update(Core.Frame, true);

                // notify Ascension this property changed
                storage.PropertyChanged(obj.OffsetProperties + this.OffsetProperties);

                // invoke callback
                var cb = obj.Storage.Values[obj[this]].Action;
                if (cb != null)
                {
                    cb();
                }
            }
        }
Exemplo n.º 14
0
        public override object DebugValue(NetworkObj obj, NetworkStorage storage)
        {
            var nt = obj.Storage.Values[obj[this]].Transform;

            if (nt != null && nt.Simulate)
            {
                var p = obj.Storage.Values[obj[this] + POSITION].Vector3;
                var r = obj.Storage.Values[obj[this] + ROTATION].Quaternion;

                var pos = string.Format("X:{0} Y:{1} Z:{2}", p.x.ToString("F2"), p.y.ToString("F2"), p.z.ToString("F2"));
                var rot = string.Format("X:{0} Y:{1} Z:{2}", r.x.ToString("F2"), r.y.ToString("F2"), r.z.ToString("F2"));

                var render = "";

                if (nt.Render)
                {
                    render = string.Format("(R: {0})", nt.Render.gameObject.name);
                }

                return(string.Format("{0} / {1}{2}", pos, rot, render));
            }

            return("NOT ASSIGNED");
        }
Exemplo n.º 15
0
 public void FreeStorage(NetworkStorage storage)
 {
     Meta.FreeStorage(storage);
 }
Exemplo n.º 16
0
 public virtual object DebugValue(NetworkObj obj, NetworkStorage storage)
 {
     return("NONE");
 }
Exemplo n.º 17
0
 public Event(Event_Meta meta)
     : base(meta)
 {
     Meta    = meta;
     storage = AllocateStorage();
 }
Exemplo n.º 18
0
 public abstract bool Write(Connection connection, NetworkObj obj, NetworkStorage storage, Packet packet);
Exemplo n.º 19
0
 public abstract void Read(Connection connection, NetworkObj obj, NetworkStorage storage, Packet packet);
Exemplo n.º 20
0
 public virtual void OnFrameCloned(NetworkObj obj, NetworkStorage storage)
 {
 }
Exemplo n.º 21
0
 public virtual void SmoothCommandCorrection(NetworkObj obj, NetworkStorage from, NetworkStorage to, NetworkStorage storage, float t)
 {
 }
Exemplo n.º 22
0
 public override void Read(Connection connection, NetworkObj obj, NetworkStorage storage, Packet packet)
 {
     storage.Values[obj[this]].Color = packet.ReadColorRGBA();
 }
Exemplo n.º 23
0
 public override void Read(Connection connection, NetworkObj obj, NetworkStorage storage, Packet packet)
 {
     storage.Values[obj[this]].Guid = packet.ReadGuid();
 }
Exemplo n.º 24
0
 public override void Read(Connection connection, NetworkObj obj, NetworkStorage storage, Packet packet)
 {
     storage.Values[obj[this]].Matrix4x4 = packet.ReadMatrix4x4();
 }
Exemplo n.º 25
0
 public Command(Command_Meta meta)
     : base(meta)
 {
     Meta    = meta;
     storage = AllocateStorage();
 }
Exemplo n.º 26
0
 public override bool Write(Connection connection, NetworkObj obj, NetworkStorage storage, Packet packet)
 {
     Compression.Pack(packet, storage.Values[obj[this]].Float0);
     return(true);
 }
Exemplo n.º 27
0
 public override bool Write(Connection connection, NetworkObj obj, NetworkStorage storage, Packet packet)
 {
     packet.WriteGuid(storage.Values[obj[this]].Guid);
     return(true);
 }
Exemplo n.º 28
0
 public override void OnFrameCloned(NetworkObj obj, NetworkStorage storage)
 {
     storage.Values[obj[this]].TriggerLocal.Frame   = 0;
     storage.Values[obj[this]].TriggerLocal.History = 0;
 }
Exemplo n.º 29
0
 public override object DebugValue(NetworkObj obj, NetworkStorage storage)
 {
     return(storage.Values[obj[this]].Guid);
 }
Exemplo n.º 30
0
 public override void Read(Connection connection, NetworkObj obj, NetworkStorage storage, Packet packet)
 {
     storage.Values[obj[this]].Int0 = Compression.Read(packet);
 }