/// <summary>
 /// process PropulsionDB movement for a single system
 /// </summary>
 /// <param name="manager">the system to process</param>
 /// <param name="deltaSeconds">amount of time in seconds</param>
 internal static void Process(EntityManager manager, int deltaSeconds)
 {
     /*
      * OrderProcessor.ProcessSystem(manager);
      * foreach (Entity shipEntity in manager.GetAllEntitiesWithDataBlob<PropulsionDB>())
      * {
      *  PositionDB positionDB = shipEntity.GetDataBlob<PositionDB>();
      *  PropulsionDB propulsionDB = shipEntity.GetDataBlob<PropulsionDB>();
      *
      *
      *  Queue<BaseOrder> orders = new Queue<BaseOrder>();//shipEntity.GetDataBlob<ShipInfoDB>().Orders;
      *
      *  if(orders.Count > 0)
      *  {
      *
      *      if (orders.Peek().OrderType == orderType.MOVETO)
      *      {
      *
      *          // Check to see if we will overtake the target
      *
      *          //MoveOrder order = (MoveOrder)orders.Peek();
      *          Vector4 shipPos = positionDB.AbsolutePosition;
      *          Vector4 targetPos;
      *          Vector4 currentSpeed = shipEntity.GetDataBlob<PropulsionDB>().CurrentVector;
      *          Vector4 nextTPos = shipPos + (currentSpeed * deltaSeconds);
      *          Vector4 newPos = shipPos;
      *          Vector4 deltaVecToTarget;
      *          Vector4 deltaVecToNextT;
      *
      *          double distanceToTarget;
      *          double distanceToNextTPos;
      *
      *          double speedDelta;
      *          double distanceDelta;
      *          double newDistanceDelta;
      *          double fuelMaxDistanceAU;
      *
      *          double currentSpeedLength = currentSpeed.Length();
      *          StaticDataStore staticData = manager.Game.StaticData;
      *          CargoStorageDB storedResources = shipEntity.GetDataBlob<CargoStorageDB>();
      *          Dictionary<Guid, double> fuelUsePerMeter = propulsionDB.FuelUsePerKM;
      *          double maxKMeters = CalcMaxFuelDistance(shipEntity);
      *
      *          if (order.PositionTarget == null)
      *              targetPos = order.Target.GetDataBlob<PositionDB>().AbsolutePosition;
      *          else
      *              targetPos = order.PositionTarget.AbsolutePosition;
      *
      *          deltaVecToTarget = shipPos - targetPos;
      *
      *          distanceToTarget = deltaVecToTarget.Length();  //in au
      *
      *
      *          deltaVecToNextT = shipPos - nextTPos;
      *          fuelMaxDistanceAU = GameConstants.Units.KmPerAu * maxKMeters;
      *
      *
      *          distanceToNextTPos = deltaVecToNextT.Length();
      *          if (fuelMaxDistanceAU < distanceToNextTPos)
      *          {
      *              newDistanceDelta = fuelMaxDistanceAU;
      *              double percent = fuelMaxDistanceAU / distanceToNextTPos;
      *              newPos = nextTPos + deltaVecToNextT * percent;
      *              Event usedAllFuel = new Event(manager.ManagerSubpulses.SystemLocalDateTime, "Used all Fuel", shipEntity.GetDataBlob<OwnedDB>().OwnedByFaction, shipEntity);
      *              usedAllFuel.EventType = EventType.FuelExhausted;
      *              manager.Game.EventLog.AddEvent(usedAllFuel);
      *          }
      *          else
      *          {
      *              newDistanceDelta = distanceToNextTPos;
      *              newPos = nextTPos;
      *          }
      *
      *
      *
      *          if (distanceToTarget < newDistanceDelta) // moving would overtake target, just go directly to target
      *          {
      *              newDistanceDelta = distanceToTarget;
      *              propulsionDB.CurrentVector = new Vector4(0, 0, 0, 0);
      *              newPos = targetPos;
      *              if (order.Target != null && order.Target.HasDataBlob<SystemBodyInfoDB>())
      *                  positionDB.SetParent(order.Target);
      *              if (order.Target != null)
      *              {
      *                  if (order.Target.HasDataBlob<SystemBodyInfoDB>())  // Set position to the target body
      *                  {
      *                      positionDB.SetParent(order.Target);
      *
      *                  }
      *              }
      *
      *              else // We arrived, get rid of the order
      *              {
      *
      *                  shipEntity.GetDataBlob<ShipInfoDB>().Orders.Dequeue();
      *              }
      *
      *          }
      *          positionDB.AbsolutePosition = newPos;
      *          int kMetersMoved = (int)(newDistanceDelta * GameConstants.Units.KmPerAu);
      *          foreach (var item in propulsionDB.FuelUsePerKM)
      *          {
      *              var fuel = staticData.GetICargoable(item.Key);
      *              StorageSpaceProcessor.RemoveCargo(storedResources, fuel, (long)(item.Value * kMetersMoved));
      *          }
      *
      *      }
      *  }
      * }           */
 }
Example #2
0
 internal Entity([NotNull] EntityManager manager, [NotNull] ProtoEntity protoEntity) : this(protoEntity.Guid, manager, Guid.Empty, protoEntity.DataBlobs) { }
 public void ProcessManager(EntityManager manager, int deltaSeconds)
 {
     ShipMovementProcessor.Process(manager, deltaSeconds);
 }
Example #4
0
 internal Entity([NotNull] EntityManager manager, Guid factionOwner, IEnumerable<BaseDataBlob> dataBlobs = null) : this(Guid.NewGuid(), manager,  factionOwner, dataBlobs) { }
Example #5
0
 internal Entity([NotNull] EntityManager manager, Guid factionID, [NotNull] ProtoEntity protoEntity) : this(protoEntity.Guid, manager, factionID, protoEntity.DataBlobs) { }
Example #6
0
 public Entity Clone(EntityManager manager)
 {
     ProtoEntity clone = Clone();
     clone.Guid = Guid.NewGuid();
     return new Entity(manager, clone);
 }
Example #7
0
 /// <summary>
 /// Create an entity from specified manager, faction and protoEntity.
 /// </summary>
 /// <returns>The create.</returns>
 /// <param name="manager">Manager.</param>
 /// <param name="faction">the faction owner of this new entity. use ID.Empty for a non owned entity.</param>
 /// <param name="protoEntity">Proto entity.</param>
 public static Entity Create(EntityManager manager, Guid faction, ProtoEntity protoEntity)
 {
     return new Entity(protoEntity.Guid, manager, faction, protoEntity.DataBlobs);
 }
Example #8
0
 public OrderQueue(EntityManager em)
 {
     _orderList = new List <BaseOrder>();
     //_entityManager = em;
 }
Example #9
0
        public static Entity ImportEntity([NotNull] Game game, [NotNull] Stream inputStream, [NotNull] EntityManager manager)
        {
            if (manager == null)
            {
                throw new ArgumentNullException(nameof(manager));
            }

            var protoEntity = new ProtoEntity();

            protoEntity = Import(game, inputStream, protoEntity);
            Entity entity = Entity.Create(manager, protoEntity);

            game.PostGameLoad();
            return(entity);
        }
Example #10
0
 public static Entity ImportEntityJson([NotNull] Game game, string jsonString, [NotNull] EntityManager manager)
 {
     using (MemoryStream stream = GetMemoryStream(jsonString))
     {
         return(ImportEntity(game, stream, manager));
     }
 }