Skip to content
Permalink
Browse files

[296] Subsciption-Events konkretisiert

  • Loading branch information...
tomwendel committed Dec 10, 2015
1 parent 8e480fa commit 1ac5ed7746861c46fe56c591226f56354f5c5fa4
@@ -60,7 +60,10 @@ public ClientComponent(OctoGame game) : base(game)
ChunkSerializer serializer = new ChunkSerializer();
return serializer.Deserialize(stream, position);
}
}, (position, chunk) => { } );
}, (position, chunk) =>
{
client.UnsubscribeChunk(position.Planet, position.ChunkIndex.X, position.ChunkIndex.Y, position.ChunkIndex.Z);
});
}

public override void Initialize()
@@ -147,6 +150,36 @@ public void SendPlayerLeave(Guid client)
otherPlayers.Remove(c);
}

public void SendBlockRemove(int planet, int chunkX, int chunkY, int chunkZ, int blockX, int blockY, int blockZ)
{
throw new NotImplementedException();
}

public void SendBlockInsert(int planet, int chunkX, int chunkY, int chunkZ, int blockX, int blockY, int blockZ, string fullName, int metaData)
{
throw new NotImplementedException();
}

public void SendEntityInsert(int planet, int chunkX, int chunkY, int chunkZ, Guid id, string fullName, byte[] data)
{
throw new NotImplementedException();
}

public void SendEntityRemove(Guid id)
{
throw new NotImplementedException();
}

public void SendEntityMove(Guid id, int planet, int chunkX, int chunkY, int chunkZ)
{
throw new NotImplementedException();
}

public void SendEntityUpdate(Guid id, byte[] data)
{
throw new NotImplementedException();
}

public delegate void DisconnectDelegate(string reason);

public event DisconnectDelegate OnDisconnect;
@@ -47,6 +47,11 @@ public void Initialize()
});
}

public void Uninitialize()
{
localChunkCache.GetChunk(Player.Position.ChunkIndex).Entities.Remove(Player);
}

public void Update(GameTime frameTime)
{
#region Inputverarbeitung
@@ -16,7 +16,7 @@ public class Client : IConnection

public string Playername { get; private set; }

public IPlayerController ActorHost { get; private set; }
public ActorHost ActorHost { get; private set; }

public Client()
{
@@ -161,5 +161,11 @@ public void Interact(Index3 blockIndex)
{
ActorHost.Interact(blockIndex);
}

[OperationBehavior]
public void UnsubscribeChunk(int planet, int x, int y, int z)
{
throw new NotImplementedException();
}
}
}
@@ -55,15 +55,66 @@ public interface IConnectionCallback

#region Subscription

void SendBlockRemove();

void SendBlockInsert();

void SendEntityInsert();

void SendEntityRemove();

void SendEntityUpdate();
/// <summary>
/// Informiert den Client über das Entfernen eines einzelnen Blocks
/// </summary>
/// <param name="planet"></param>
/// <param name="chunkX"></param>
/// <param name="chunkY"></param>
/// <param name="chunkZ"></param>
/// <param name="blockX"></param>
/// <param name="blockY"></param>
/// <param name="blockZ"></param>
void SendBlockRemove(int planet, int chunkX, int chunkY, int chunkZ, int blockX, int blockY, int blockZ);

/// <summary>
/// Informiert den Client über das Einfügen eines Blocks
/// </summary>
/// <param name="planet"></param>
/// <param name="chunkX"></param>
/// <param name="chunkY"></param>
/// <param name="chunkZ"></param>
/// <param name="blockX"></param>
/// <param name="blockY"></param>
/// <param name="blockZ"></param>
/// <param name="fullName"></param>
/// <param name="metaData"></param>
void SendBlockInsert(int planet, int chunkX, int chunkY, int chunkZ, int blockX, int blockY, int blockZ, string fullName, int metaData);

/// <summary>
/// Informiert den Player über das einfügen einer Entität (Items, player,...)
/// </summary>
/// <param name="planet"></param>
/// <param name="chunkX"></param>
/// <param name="chunkY"></param>
/// <param name="chunkZ"></param>
/// <param name="id"></param>
/// <param name="fullName"></param>
/// <param name="data"></param>
void SendEntityInsert(int planet, int chunkX, int chunkY, int chunkZ, Guid id, string fullName, byte[] data);

/// <summary>
/// Informiert den Player über das entfernen einer Entität
/// </summary>
/// <param name="id"></param>
void SendEntityRemove(Guid id);

/// <summary>
/// Informiert den Player über den Wechsel einer Entität in einen anderen Chunk
/// </summary>
/// <param name="id"></param>
/// <param name="planet"></param>
/// <param name="chunkX"></param>
/// <param name="chunkY"></param>
/// <param name="chunkZ"></param>
void SendEntityMove(Guid id, int planet, int chunkX, int chunkY, int chunkZ);

/// <summary>
/// Informiert den Player über veränderte Entitäten-Daten
/// </summary>
/// <param name="id"></param>
/// <param name="data"></param>
void SendEntityUpdate(Guid id, byte[] data);

#endregion
}
@@ -173,6 +173,9 @@ internal void Leave(Client client)
if (OnLeave != null)
OnLeave(client);

// ActorHost entfernen
world.RemovePlayer(client.ActorHost);

// Alle anderen Clients informieren
foreach (var c in clients)
{
@@ -31,6 +31,7 @@ public ActorHost InjectPlayer(Player player)

public void RemovePlayer(ActorHost host)
{
host.Uninitialize();
updateDomains[0].ActorHosts.Remove(host);
}
}
@@ -69,6 +69,14 @@ public ushort[][] Resources
}
}

public ICollection<Entity> Entities
{
get
{
throw new NotImplementedException();
}
}

public ushort GetBlock(Index3 index)
{
throw new NotImplementedException();
@@ -39,7 +39,7 @@ public sealed class Chunk : IChunk

public ushort[][] Resources { get; private set; }

public List<Entity> Entities { get; private set; }
public ICollection<Entity> Entities { get; private set; }


/// <summary>
@@ -19,5 +19,9 @@ public abstract class Entity

[XmlIgnore]
public Vector3 ExternalForce { get; set; }

public abstract void SetData(byte[] data);

public abstract byte[] GetData();
}
}
@@ -1,6 +1,7 @@
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using System.Xml.Serialization;
using System;

namespace OctoAwesome
{
@@ -44,5 +45,15 @@ public Player()
Mass = 100;
FlyMode = false;
}

public override void SetData(byte[] data)
{
throw new NotImplementedException();
}

public override byte[] GetData()
{
throw new NotImplementedException();
}
}
}

0 comments on commit 1ac5ed7

Please sign in to comment.
You can’t perform that action at this time.