public override void Init(Scene s)
 {
     if (s != null)
     {
         Debug.Log("replicator initializing");
         Clock = s.DependencyResolver.GetComponent<IClock>();
         s.AddProcedure("RequestObjects", OnRequestObjects);
         s.AddRoute("PlayerDisconnected", OnPlayerDisconnect);
         s.AddRoute("CreateObject", OnCreateObject);
         s.AddRoute("DestroyObject", OnDestroyObject);
         s.AddRoute("ForceUpdate", OnForceUpdate);
         s.AddRoute("UpdateObject", OnUpdateObject);
     }
 }
Beispiel #2
0
    public override void SendChanges(Stream stream)
    {
        if (Clock == null)
        {
            Clock = Scene.Scene.DependencyResolver.Resolve<Stormancer.IClock>();
        }
        if (PlayerRigidbody == null)
        {
            PlayerRigidbody = this.GetComponent<Rigidbody>();
        }
        using (var writer = new BinaryWriter(stream, System.Text.Encoding.UTF8))
        {

            writer.Write(Clock.Clock);
            if (SendPositionX == true)
                writer.Write(this.transform.position.x);
            if (SendPositionY == true)
                writer.Write(this.transform.position.y);
            if (SendPositionZ == true)
                writer.Write(this.transform.position.z);

            if (SendPositionX == true)
                writer.Write(PlayerRigidbody.velocity.x);
            if (SendPositionY == true)
                writer.Write(PlayerRigidbody.velocity.y);
            if (SendPositionZ == true)
                writer.Write(PlayerRigidbody.velocity.z);

            var rot = this.transform.rotation.eulerAngles;

            if (SendRotationX == true)
                writer.Write(rot.x);
            if (SendRotationY == true)
                writer.Write(rot.y);
            if (SendRotationZ == true)
                writer.Write(rot.z);
        }
    }