public void RegisterCreation(ShipCreatedDto shipDto) { var shipCreatedEvent = new CreatedEvent { X = shipDto.x, Y = shipDto.y, Rotation = shipDto.rot, Team = shipDto.team, TimeStamp = shipDto.timestamp }; this.InsertInHistory(shipCreatedEvent); }
//private void OnShipAdded(Packet<IScenePeer> obj) //{ // var shipInfos = obj.ReadObject<ShipCreatedDto>(); // var rot = Quaternion.Euler(0, 0, shipInfos.rot * (180 / (float)Math.PI)); // var ship = new Ship { Id = shipInfos.id, LastRot = rot, TargetRot = rot, Target = new Vector3(shipInfos.x, shipInfos.y), Last = new Vector3(shipInfos.x, shipInfos.y), TargetDate = DateTime.UtcNow }; // UnityEngine.Debug.Log(string.Format("Ship {0} added ", shipInfos.id)); // _gameObjects.Add(ship.Id, ship); //} private void OnShipAdded(ShipCreatedDto[] shipDtos) { foreach (var shipDto in shipDtos) { ShipStateManager ship; if (!_gameObjects.TryGetValue(shipDto.id, out ship)) { ship = new ShipStateManager(); ship = _gameObjects.AddOrUpdate(shipDto.id, ship, (_, val) => val); } ship.RegisterCreation(shipDto); } }