public List <IVehicleCmd> GetCmdList(int simulationStartTime, int simulationEndTime)
        {
            if (!_playerEntity.hasVehicleCmd)
            {
                _playerEntity.AddVehicleCmd();
            }

            return(_playerEntity.vehicleCmd.GetBetween(simulationStartTime, simulationEndTime));
        }
Esempio n. 2
0
        public static void AddVehicleComponentsPostInit(this VehicleEntity vehicle, EVehicleType type, UnityObject unityObj, PlayerContext playerContext, bool isServer)
        {
            var go = unityObj.AsGameObject;

            if (!vehicle.hasGameObject)
            {
                var controller = go.GetComponent <VehicleCommonController>();
                vehicle.AddGameObject(controller, unityObj);
                controller.PutToSleep();
            }

            if (!go.activeSelf)
            {
                var controller = go.GetComponent <VehicleCommonController>();
                controller.IsActive = true;
            }

            go.transform.position = GetNewBirthPositionOnOverlap(go);

            if (vehicle.HasDynamicData())
            {
                var dydata = vehicle.GetDynamicData();
                dydata.Position = go.transform.position;
            }

            if (!vehicle.hasVehicleType)
            {
                vehicle.AddVehicleType(type);
            }

            vehicle.AddEntityKeyIdentifier(vehicle.entityKey.Value);
            vehicle.AddVehicleObjectCollision(playerContext);

            vehicle.AddSeatComponent();
            vehicle.AddDynamicAndEffectDataPostInit();

            vehicle.AddVehicleAllGameData();
            vehicle.AddHitBoxComponent();
            vehicle.AddGameEventComponent();

            if (!vehicle.hasVehicleCmd)
            {
                vehicle.AddVehicleCmd();
            }

            if (!vehicle.hasVehicleCmdOwner)
            {
                vehicle.AddVehicleCmdOwner(new VehicleCmdOwnerAdapter(vehicle));
            }

            if (!vehicle.hasVehicleSyncEvent)
            {
                vehicle.AddVehicleSyncEvent(new Queue <IVehicleSyncEvent>());
            }

            if (!vehicle.hasVehicleCollisionDamage)
            {
                vehicle.AddVehicleCollisionDamage(new Dictionary <EntityKey, VehicleCollisionDamage>(new EntityKeyComparer()));
            }

            EntityAPI[vehicle.GetTypeValue()].InitController(vehicle, isServer, vehicle.vehicleAssetInfo.Id);

            vehicle.isFlagSyncSelf     = true;
            vehicle.isFlagSyncNonSelf  = true;
            vehicle.isFlagCompensation = true;
        }