public void InitBodywork(int bodyworkID, TankComponent tank, MoveComponent move, GameobjectComponent gameobjectComponent) { gameobjectComponent.animator.SetInteger("state", 0); // enter the idle animation //gameobjectComponent.animator.SetInteger("init", 2); //EquipBodywork(EquipmentManager.GetInstance().GetBodywork(bodyworkID), tank, move, gameobjectComponent); }
void MoveControl(TankComponent tank, InputComponent input, MoveComponent move, Transform transform, GameobjectComponent gameobjectComponent) { foreach (var item in TankComponent.moveActionDict) { if (InputSystem.GetHoldAction(input, item.Key)) { move.moveDirection = item.Value; } } move.needMove = false; foreach (var item in TankComponent.moveActionDict) { if (InputSystem.GetHoldAction(input, item.Key)) { move.needMove = true; break; } } if (move.needMove == true) { //Debug.Log("need move is true"); gameobjectComponent.animator.SetInteger("state", 1); transform.rotation = Quaternion.Euler(0, 0, move.moveDirection * 90); } else { move.moveDirection = -1; gameobjectComponent.animator.SetInteger("state", 0); } }
public override void OnUpdate(float deltaTime) { if (onTankShootRequestedEvent.IsPublished) { foreach (var networkViewIDStr in onTankShootRequestedEvent.BatchedChanges) { int networkViewID = int.Parse(networkViewIDStr); PlayerProvider playerProvider = null; foreach (var p in playersFilter) { ref PlayerComponent pc = ref p.GetComponent <PlayerComponent>(); if (pc.networkPlayer.networkViewID == networkViewID) { playerProvider = pc.networkPlayer.GetPlayerProvider(); break; } } if (playerProvider == null) { continue; } Entity tankEntity = playerProvider.Entity; ref TankComponent tank = ref tankEntity.GetComponent <TankComponent>(); ProjectileProvider pp = ObjectSpawner.inst.InstantiateBullet(); ref ProjectileComponent projectile = ref pp.Entity.GetComponent <ProjectileComponent>();
public override void OnUpdate(float deltaTime) { bool updateAnimation = tankAnimationUpdateTimer.Check(); foreach (var ent in tanksFilter) { ref TankComponent tankComponent = ref ent.GetComponent <TankComponent>(); ref TankRenderComponent tankRenderComponent = ref ent.GetComponent <TankRenderComponent>();
public static void OnTakeBackPointerUp_Postfix(UITankWindow __instance) { if (Multiplayer.IsActive) { TankComponent thisTank = __instance.storage.tankPool[__instance.tankId]; Multiplayer.Session.Network.SendPacketToLocalStar(new TankStorageUpdatePacket(in thisTank, GameMain.localPlanet?.id ?? -1)); } }
public TestStandMapping() { PT_N2 = new PressureComponent(16, "PT_N2", "PT-N2", 400); PT_IPA = new PressureComponent(17, "PT_IPA", "PT-IPA", 50); PT_N2O = new PressureComponent(18, "PT_N2O", "PT-N2O", 50); PT_FUEL = new PressureComponent(19, "PT_FUEL", "PT-FUEL", 50); PT_OX = new PressureComponent(20, "PT_OX", "PT-OX", 50); PT_CHAM = new PressureComponent(21, "PT_CHAM", "PT-CHAM", 50); TC_IPA = new TemperatureComponent(8, "TC_IPA", "TC-IPA", x => x); TC_N2O = new TemperatureComponent(9, "TC_N2O", "TC-N2O", x => x); TC_1 = new TemperatureComponent(10, "TC_1", "TC-1", x => x); TC_2 = new TemperatureComponent(11, "TC_2", "TC-2", x => x); TC_3 = new TemperatureComponent(12, "TC_3", "TC-3", x => x); TC_4 = new TemperatureComponent(13, "TC_4", "TC-4", x => x); TC_5 = new TemperatureComponent(14, "TC_5", "TC-5", x => x); TC_6 = new TemperatureComponent(15, "TC_6", "TC-6", x => x); LOAD = new LoadComponent(0, "LOAD", "Load cell"); SV_IPA = new SolenoidComponent(4, "SV_IPA", "SV-IPA", "SV_IPA_SYMBOL"); SV_N2O = new SolenoidComponent(5, "SV_N2O", "SV-N2O", "SV_N2O_SYMBOL"); MV_IPA = new ServoComponent(6, "MV_IPA", "MV-IPA", "MV_IPA_SYMBOL"); MV_N2O = new ServoComponent(7, "MV_N2O", "MV-N2O", "MV_N2O_SYMBOL"); TARGET_MV_IPA = new SimpleComponent(25, 2, false, "TARGET-MV-IPA", "TARGET-MV-IPA [%]", x => ((float)x) / ushort.MaxValue * 100.0f); TARGET_MV_N2O = new SimpleComponent(26, 2, false, "TARGET-MV-N20", "TARGET-MV-N20 [%]", x => ((float)x) / ushort.MaxValue * 100.0f); SN_N2O_FILL = new SolenoidComponent(2, "SN_N2O_FILL", "SN-N2O-FILL", "SN_N2O_FILL_SYMBOL"); SN_FLUSH = new SolenoidComponent(3, "SN_FLUSH", "SN-FLUSH", "SN_FLUSH_SYMBOL"); BATTERY = new VoltageComponent(22, "BATTERY", "BATTERY", 12.0f, 14.8f); FLO_IPA = new FlowComponent(100, "FLO_IPA", "FLO-IPA", ref PT_FUEL, ref PT_CHAM, () => PreferenceManager.Manager.Preferences.Fluid.Fuel); FLO_N2O = new FlowComponent(101, "FLO_N2O", "FLO-N2O", ref PT_N2O, ref PT_CHAM, () => PreferenceManager.Manager.Preferences.Fluid.Oxid); T_IPA = new TankComponent(24, "FUEL", "FUEL", "FUEL_GRADIENT", ref FLO_IPA, "Fuel"); T_N2O = new LevelComponent(1, "OXID", "OXID", "OXID_GRADIENT", 20); STACK_HEALTH = new StackHealthComponent(23, "STACK_MAIN", "STACK_ACTUATOR", "STACK_SENSOR", "STACK-HEALTH"); _states = new List <State> { new State(0, "Idle"), new State(1, "Ignition"), new State(2, "Pre-Stage 1"), new State(3, "Pre-Stage 2"), new State(4, "Ramp up"), new State(5, "Regulated"), new State(6, "Shutdown 1"), new State(7, "Shutdown 2"), new State(8, "Flush") }; EmergencyState = _states[6]; PreferenceManager.Manager.Preferences.AutoSequenceComponentIDs.ChamberPressureID = PT_CHAM.BoardID; PreferenceManager.Manager.Preferences.AutoSequenceComponentIDs.FuelLinePressureID = PT_FUEL.BoardID; PreferenceManager.Manager.Preferences.AutoSequenceComponentIDs.OxidizerLinePressureID = PT_OX.BoardID; }
public static void _OnUpdate_Postfix(UITankWindow __instance) { if (pointerPress) { //Send update for inserting or withdrawing TankComponent thisTank = __instance.storage.tankPool[__instance.tankId]; LocalPlayer.SendPacketToLocalPlanet(new TankStorageUpdatePacket(__instance.tankId, thisTank.fluidId, thisTank.fluidCount)); } }
public void Update(TankComponent tank, InputComponent input, MoveComponent move, GameobjectComponent gameobjectComponent) { if (tank == null || tank.enable == false) { return; } //Debug.Log("contorller system update, entity tag: " + tank.entity.identity.tag); MoveControl(tank, input, move, gameobjectComponent.transform, gameobjectComponent); }
public static void _OnUpdate_Postfix(UITankWindow __instance) { if (pointerPress && SimulatedWorld.Initialized) { //Send update for inserting or withdrawing TankComponent thisTank = __instance.storage.tankPool[__instance.tankId]; LocalPlayer.SendPacketToLocalStar(new TankStorageUpdatePacket(__instance.tankId, thisTank.fluidId, thisTank.fluidCount, GameMain.localPlanet?.factoryIndex ?? -1)); } }
//void GenerateGun(Entity entity) //{ // Entity gunEntity = world.entitySystem.NewPawn(gunPrefab, entity.gameobjectComponent.transform.position); // gunEntity.identity.master = entity; //} void EquipBodywork(Bodywork bodywork, TankComponent tank, MoveComponent move, GameobjectComponent gameobjectComponent) { tank.bodywork = bodywork; gameobjectComponent.animator.SetInteger("init", bodywork.animTrigger); var sprite = Resources.Load <Sprite>(bodywork.spritePath); gameobjectComponent.spriteRenderer.sprite = sprite; move.moveSpeed = bodywork.moveSpeed; //GetComponent<Life>().SetHP(b.hp); }
//void GenerateGun(Entity entity) //{ // Entity gunEntity = world.entitySystem.NewPawn(gunPrefab, entity.gameobjectComponent.transform.position); // gunEntity.identity.master = entity; //} void EquipBodywork(Bodywork bodywork, TankComponent tank, MoveComponent move, GameobjectComponent gameobjectComponent) { tank.bodywork = bodywork; gameobjectComponent.animator.SetInteger("init", bodywork.animTrigger); var sprite = Resources.Load <Sprite>(bodywork.spritePath); gameobjectComponent.spriteRenderer.sprite = sprite; move.moveSpeed = bodywork.moveSpeed; world.lifeSystem.SetData(move.entity.lifeComponent, bodywork.hp); Debug.Log("EquipBodywork:" + bodywork.spritePath); }
public void SetBotSkin(ref TankComponent botTankComponent, BotColors color) { botTankComponent.TankParts[(int)TankParts.BODY].sprite = botBodySprites[(int)botTankComponent.TankLevel]; botTankComponent.TankParts[(int)TankParts.LIGHT].sprite = botLightSprites[(int)botTankComponent.TankLevel]; botTankComponent.TankParts[(int)TankParts.SHADOW].sprite = botShadowSprites[(int)botTankComponent.TankLevel]; botTankComponent.TankParts[(int)TankParts.WHEEL_BODY].sprite = botWheelBodySprites[(int)botTankComponent.TankLevel]; botTankComponent.TankParts[(int)TankParts.WHEEL_LIGHT].sprite = botWheelLightSprites[(int)botTankComponent.TankLevel]; botTankComponent.TankParts[(int)TankParts.WHEEL_SHADOW].sprite = botWheelShadowSprites[(int)botTankComponent.TankLevel]; botTankComponent.TankParts[(int)TankParts.BODY].color = botBodyColors[(int)color]; botTankComponent.TankParts[(int)TankParts.LIGHT].color = botLightColors[(int)color]; botTankComponent.TankParts[(int)TankParts.SHADOW].color = botShadowColors[(int)color]; botTankComponent.TankParts[(int)TankParts.WHEEL_BODY].color = botBodyColors[(int)color]; botTankComponent.TankParts[(int)TankParts.WHEEL_LIGHT].color = botLightColors[(int)color]; botTankComponent.TankParts[(int)TankParts.WHEEL_SHADOW].color = botShadowColors[(int)color]; }
public void SetPlayerSkin(ref TankComponent playerTankComponent, ref PlayerComponent playerComponent, PlayerColors color) { playerTankComponent.TankParts[(int)TankParts.BODY].sprite = playerBodySprites[(int)playerTankComponent.TankLevel]; playerTankComponent.TankParts[(int)TankParts.LIGHT].sprite = playerLightSprites[(int)playerTankComponent.TankLevel]; playerTankComponent.TankParts[(int)TankParts.SHADOW].sprite = playerShadowSprites[(int)playerTankComponent.TankLevel]; playerTankComponent.TankParts[(int)TankParts.WHEEL_BODY].sprite = playerWheelBodySprites[(int)playerTankComponent.TankLevel]; playerTankComponent.TankParts[(int)TankParts.WHEEL_LIGHT].sprite = playerWheelLightSprites[(int)playerTankComponent.TankLevel]; playerTankComponent.TankParts[(int)TankParts.WHEEL_SHADOW].sprite = playerWheelShadowSprites[(int)playerTankComponent.TankLevel]; playerTankComponent.TankParts[(int)TankParts.BODY].color = playerBodyColors[(int)color]; playerTankComponent.TankParts[(int)TankParts.LIGHT].color = playerLightColors[(int)color]; playerTankComponent.TankParts[(int)TankParts.SHADOW].color = playerShadowColors[(int)color]; playerTankComponent.TankParts[(int)TankParts.WHEEL_BODY].color = playerBodyColors[(int)color]; playerTankComponent.TankParts[(int)TankParts.WHEEL_LIGHT].color = playerLightColors[(int)color]; playerTankComponent.TankParts[(int)TankParts.WHEEL_SHADOW].color = playerShadowColors[(int)color]; playerComponent.ShieldRenderer.color = playerBodyColors[(int)color]; }
protected override void Run(ETModel.Session session, B2C_CreateTanks message) { Log.Warning("收到消息 B2C_CreateTanks"); Log.Warning("进入战场,坦克数量=" + message.Tanks.Count); TankComponent tankComponent = ETModel.Game.Scene.GetComponent <TankComponent>(); // 第一次进入战场,先创建自己坦克(创建其他坦克时需要判断与自己坦克关系,所以先创建自己坦克) if (tankComponent.MyTank == null) { foreach (TankInfoFirstEnter firstInfo in message.Tanks) { TankFrameInfo tankInfo = firstInfo.TankFrameInfo; if (tankInfo.TankId == PlayerComponent.Instance.MyPlayer.TankId) { Vector3 pos = new Vector3(tankInfo.PX * 1f / Tank.m_coefficient, tankInfo.PY * 1f / Tank.m_coefficient, tankInfo.PZ * 1f / Tank.m_coefficient); Vector3 rot = new Vector3(tankInfo.RX * 1f / Tank.m_coefficient, tankInfo.RY * 1f / Tank.m_coefficient, tankInfo.RZ * 1f / Tank.m_coefficient); Tank tank = TankFactory.Create(firstInfo, pos, rot); break; } } } foreach (TankInfoFirstEnter firstInfo in message.Tanks) { TankFrameInfo tankInfo = firstInfo.TankFrameInfo; if (tankComponent.Get(tankInfo.TankId) != null) { continue; } Vector3 pos = new Vector3(tankInfo.PX * 1f / Tank.m_coefficient, tankInfo.PY * 1f / Tank.m_coefficient, tankInfo.PZ * 1f / Tank.m_coefficient); Vector3 rot = new Vector3(tankInfo.RX * 1f / Tank.m_coefficient, tankInfo.RY * 1f / Tank.m_coefficient, tankInfo.RZ * 1f / Tank.m_coefficient); Tank tank = TankFactory.Create(firstInfo, pos, rot); } Game.EventSystem.Run(EventIdType.CreateTanksFinish); }
public override EventResult Process(Logger logger) { double damage = 0.0; if (_attacker is Tank) { damage = CalculateTankDamage(_attacker as Tank); if (damage == 0) { logger.Log($"{_attacker.Name} tried hitting {_target.Name}, but missed."); } } // Only hit undestroyed components var possibleHits = new TankComponent[] { _target.MainBody, _target.RoadWheel, _target.Barrel } .Where(t => !t.IsDestroyed) .ToList(); var hit = possibleHits[_random.Next(possibleHits.Count())]; logger.Log($"{_attacker.Name} hits {_target.Name}'s {hit.Name} for {damage} damage."); hit.GetHit(damage); if (_target.IsDestroyed) { var winner = _attacker is Landmine ? (_attacker as Landmine).Owner : _attacker as Tank; var tankDestroyedEvent = new TankDestroyedEvent(winner, _target); tankDestroyedEvent.Process(logger); } if (hit == _target.RoadWheel && _target.RoadWheel.IsDestroyed) { logger.Log($"{_target.Name}'s road wheels are destroyed! {_target.Name} can't move."); } if (hit == _target.Barrel && _target.Barrel.IsDestroyed) { logger.Log($"{_target.Name}'s barrel is destroyed!"); var resultEvent = new EventResult(); resultEvent.ChainEvent = new TankBarrelRepairingEvent(_target, 2); return(resultEvent); } return(EventResult.Succeeded); }
public void Validate_Correct_Volume_Calculation() { TestStandMapping mapping = new TestStandMapping(); Session session = new Session(mapping); float fuelCV = 0.0738f; float fuelDens = 786; PressureComponent p1 = (mapping.ComponentsByID()[19] as PressureComponent); PressureComponent p2 = (mapping.ComponentsByID()[21] as PressureComponent); FlowComponent fl = (mapping.ComponentsByID()[100] as FlowComponent); TankComponent tc = (mapping.ComponentsByID()[24] as TankComponent); tc.SetInputVolume(0, 4); p2.Set(0); p1.Set(670); // 670.2545453 = 10 bar fl.Compute(); tc.Compute(0); p1.Set(730); // 729.8327273 = 12 bar fl.Compute(); tc.Compute(750); p1.Set(789); // 789.4109090 = 14 bar fl.Compute(); tc.Compute(1500); p1.Set(849); // 848.9890910 = 16 bar fl.Compute(); tc.Compute(2250); p1.Set(909); // 908.5672727 = 18 bar fl.Compute(); tc.Compute(3000); float volume = tc.CurrentVolume; Assert.AreEqual(3.832606742, volume, 0.1); }
public static bool TankGameTickPatch(ref TankComponent __instance, PlanetFactory factory) { if (!__instance.isBottom) { return(false); } //添加对不同液体的分别设置 List <int> SpecialFluid = new List <int>(); if (HOverFlow.Value) { SpecialFluid.Add(1120); } if (ROilOverFlow.Value) { SpecialFluid.Add(1114); } if (DOverFlow.Value) { SpecialFluid.Add(1121); } if (SulOverFlow.Value) { SpecialFluid.Add(1116); } if (WaterOverFlow.Value) { SpecialFluid.Add(1000); } if (OilOverFlow.Value) { SpecialFluid.Add(1007); } CargoTraffic cargoTraffic = factory.cargoTraffic; FactoryStorage factoryStorage = factory.factoryStorage; if (__instance.belt0 > 0) { if (__instance.isOutput0 && __instance.outputSwitch) { if (__instance.fluidId > 0 && __instance.currentCount <= __instance.fluidStorageCount && __instance.currentCount > 0 && cargoTraffic.TryInsertItemAtHead(__instance.belt0, __instance.fluidId)) { __instance.currentCount--; } } else if (!__instance.isOutput0 && __instance.inputSwitch) { if (__instance.fluidId > 0 && __instance.currentCount < __instance.fluidStorageCount && cargoTraffic.TryPickItemAtRear(__instance.belt0, __instance.fluidId, null) > 0) { __instance.currentCount++; } else if (__instance.fluidId > 0 && __instance.currentCount >= __instance.fluidStorageCount && SpecialFluid.Contains(__instance.fluidId) && __instance.nextTankId <= 0 && cargoTraffic.TryPickItemAtRear(__instance.belt0, __instance.fluidId, null) > 0) { } if (__instance.fluidId == 0) { int num = cargoTraffic.TryPickItemAtRear(__instance.belt0, 0, ItemProto.fluids); if (num > 0) { __instance.fluidId = num; __instance.currentCount++; } } if (__instance.currentCount >= __instance.fluidStorageCount && cargoTraffic.GetItemIdAtRear(__instance.belt0) == __instance.fluidId && __instance.nextTankId > 0) { TankComponent tankComponent = factoryStorage.tankPool[__instance.nextTankId]; TankComponent tankComponent2 = tankComponent; while (tankComponent.currentCount >= tankComponent.fluidStorageCount) { if (!tankComponent.inputSwitch) { tankComponent2 = factoryStorage.tankPool[tankComponent2.lastTankId]; break; } if (tankComponent.nextTankId <= 0) { tankComponent2.id = __instance.id; break; } tankComponent = factoryStorage.tankPool[tankComponent.nextTankId]; tankComponent2 = tankComponent; } if (!tankComponent2.inputSwitch) { tankComponent2 = factoryStorage.tankPool[tankComponent2.lastTankId]; } bool flag = true; TankComponent tankComponent3 = factoryStorage.tankPool[tankComponent2.lastTankId]; if (((tankComponent2.id == __instance.id || tankComponent2.currentCount >= tankComponent2.fluidStorageCount) && !SpecialFluid.Contains(__instance.fluidId)) || !tankComponent3.outputSwitch) { flag = false; } if (flag && cargoTraffic.TryPickItemAtRear(__instance.belt0, __instance.fluidId, null) > 0) { if (factoryStorage.tankPool[tankComponent2.id].currentCount == 0) { factoryStorage.tankPool[tankComponent2.id].fluidId = __instance.fluidId; } TankComponent[] tankPool = factoryStorage.tankPool; int num2 = tankComponent2.id; tankPool[num2].currentCount = tankPool[num2].currentCount + 1; if (tankPool[num2].currentCount > tankPool[num2].fluidStorageCount) { tankPool[num2].currentCount = tankPool[num2].fluidStorageCount; } } } } } if (__instance.belt1 > 0) { if (__instance.isOutput1 && __instance.outputSwitch) { if (__instance.fluidId > 0 && __instance.currentCount <= __instance.fluidStorageCount && __instance.currentCount > 0 && cargoTraffic.TryInsertItemAtHead(__instance.belt1, __instance.fluidId)) { __instance.currentCount--; } } else if (!__instance.isOutput1 && __instance.inputSwitch) { if (__instance.fluidId > 0 && __instance.currentCount < __instance.fluidStorageCount && cargoTraffic.TryPickItemAtRear(__instance.belt1, __instance.fluidId, null) > 0) { __instance.currentCount++; } else if (__instance.fluidId > 0 && __instance.currentCount >= __instance.fluidStorageCount && SpecialFluid.Contains(__instance.fluidId) && __instance.nextTankId <= 0 && cargoTraffic.TryPickItemAtRear(__instance.belt1, __instance.fluidId, null) > 0) { } if (__instance.fluidId == 0) { int num3 = cargoTraffic.TryPickItemAtRear(__instance.belt1, 0, ItemProto.fluids); if (num3 > 0) { __instance.fluidId = num3; __instance.currentCount++; } } if (__instance.currentCount >= __instance.fluidStorageCount && cargoTraffic.GetItemIdAtRear(__instance.belt1) == __instance.fluidId && __instance.nextTankId > 0) { TankComponent tankComponent4 = factoryStorage.tankPool[__instance.nextTankId]; TankComponent tankComponent5 = tankComponent4; while (tankComponent4.currentCount >= tankComponent4.fluidStorageCount) { if (!tankComponent4.inputSwitch) { tankComponent5 = factoryStorage.tankPool[tankComponent5.lastTankId]; break; } if (tankComponent4.nextTankId <= 0) { tankComponent5.id = __instance.id; break; } tankComponent4 = factoryStorage.tankPool[tankComponent4.nextTankId]; tankComponent5 = tankComponent4; } if (!tankComponent5.inputSwitch) { tankComponent5 = factoryStorage.tankPool[tankComponent5.lastTankId]; } bool flag2 = true; TankComponent tankComponent6 = factoryStorage.tankPool[tankComponent5.lastTankId]; if (((tankComponent5.id == __instance.id || tankComponent5.currentCount >= tankComponent5.fluidStorageCount) && !SpecialFluid.Contains(__instance.fluidId)) || !tankComponent6.outputSwitch) { flag2 = false; } if (flag2 && cargoTraffic.TryPickItemAtRear(__instance.belt1, __instance.fluidId, null) > 0) { if (factoryStorage.tankPool[tankComponent5.id].currentCount == 0) { factoryStorage.tankPool[tankComponent5.id].fluidId = __instance.fluidId; } TankComponent[] tankPool2 = factoryStorage.tankPool; int num4 = tankComponent5.id; tankPool2[num4].currentCount = tankPool2[num4].currentCount + 1; if (tankPool2[num4].currentCount > tankPool2[num4].fluidStorageCount) { tankPool2[num4].currentCount = tankPool2[num4].fluidStorageCount; } } } } } if (__instance.belt2 > 0) { if (__instance.isOutput2 && __instance.outputSwitch) { if (__instance.fluidId > 0 && __instance.currentCount <= __instance.fluidStorageCount && __instance.currentCount > 0 && cargoTraffic.TryInsertItemAtHead(__instance.belt2, __instance.fluidId)) { __instance.currentCount--; } } else if (!__instance.isOutput2 && __instance.inputSwitch) { if (__instance.fluidId > 0 && __instance.currentCount < __instance.fluidStorageCount && cargoTraffic.TryPickItemAtRear(__instance.belt2, __instance.fluidId, null) > 0) { __instance.currentCount++; } else if (__instance.fluidId > 0 && __instance.currentCount >= __instance.fluidStorageCount && SpecialFluid.Contains(__instance.fluidId) && __instance.nextTankId <= 0 && cargoTraffic.TryPickItemAtRear(__instance.belt2, __instance.fluidId, null) > 0) { } if (__instance.fluidId == 0) { int num5 = cargoTraffic.TryPickItemAtRear(__instance.belt2, 0, ItemProto.fluids); if (num5 > 0) { __instance.fluidId = num5; __instance.currentCount++; } } if (__instance.currentCount >= __instance.fluidStorageCount && cargoTraffic.GetItemIdAtRear(__instance.belt2) == __instance.fluidId && __instance.nextTankId > 0) { TankComponent tankComponent7 = factoryStorage.tankPool[__instance.nextTankId]; TankComponent tankComponent8 = tankComponent7; while (tankComponent7.currentCount >= tankComponent7.fluidStorageCount) { if (!tankComponent7.inputSwitch) { tankComponent8 = factoryStorage.tankPool[tankComponent8.lastTankId]; break; } if (tankComponent7.nextTankId <= 0) { tankComponent8.id = __instance.id; break; } tankComponent7 = factoryStorage.tankPool[tankComponent7.nextTankId]; tankComponent8 = tankComponent7; } if (!tankComponent8.inputSwitch) { tankComponent8 = factoryStorage.tankPool[tankComponent8.lastTankId]; } bool flag3 = true; TankComponent tankComponent9 = factoryStorage.tankPool[tankComponent8.lastTankId]; if (((tankComponent8.id == __instance.id || tankComponent8.currentCount >= tankComponent8.fluidStorageCount) && !SpecialFluid.Contains(__instance.fluidId)) || !tankComponent9.outputSwitch) { flag3 = false; } if (flag3 && cargoTraffic.TryPickItemAtRear(__instance.belt2, __instance.fluidId, null) > 0) { if (factoryStorage.tankPool[tankComponent8.id].currentCount == 0) { factoryStorage.tankPool[tankComponent8.id].fluidId = __instance.fluidId; } TankComponent[] tankPool3 = factoryStorage.tankPool; int num6 = tankComponent8.id; tankPool3[num6].currentCount = tankPool3[num6].currentCount + 1; if (tankPool3[num6].currentCount > tankPool3[num6].fluidStorageCount) { tankPool3[num6].currentCount = tankPool3[num6].fluidStorageCount; } } } } } if (__instance.belt3 > 0) { if (__instance.isOutput3 && __instance.outputSwitch) { if (__instance.fluidId > 0 && __instance.currentCount <= __instance.fluidStorageCount && __instance.currentCount > 0 && cargoTraffic.TryInsertItemAtHead(__instance.belt3, __instance.fluidId)) { __instance.currentCount--; } } else if (!__instance.isOutput3 && __instance.inputSwitch) { if (__instance.fluidId > 0 && __instance.currentCount < __instance.fluidStorageCount && cargoTraffic.TryPickItemAtRear(__instance.belt3, __instance.fluidId, null) > 0) { __instance.currentCount++; } else if (__instance.fluidId > 0 && __instance.currentCount >= __instance.fluidStorageCount && SpecialFluid.Contains(__instance.fluidId) && __instance.nextTankId <= 0 && cargoTraffic.TryPickItemAtRear(__instance.belt3, __instance.fluidId, null) > 0) { } if (__instance.fluidId == 0) { int num7 = cargoTraffic.TryPickItemAtRear(__instance.belt3, 0, ItemProto.fluids); if (num7 > 0) { __instance.fluidId = num7; __instance.currentCount++; } } if (__instance.currentCount >= __instance.fluidStorageCount && cargoTraffic.GetItemIdAtRear(__instance.belt3) == __instance.fluidId && __instance.nextTankId > 0) { TankComponent tankComponent10 = factoryStorage.tankPool[__instance.nextTankId]; TankComponent tankComponent11 = tankComponent10; while (tankComponent10.currentCount >= tankComponent10.fluidStorageCount) { if (!tankComponent10.inputSwitch) { tankComponent11 = factoryStorage.tankPool[tankComponent11.lastTankId]; break; } if (tankComponent10.nextTankId <= 0) { tankComponent11.id = __instance.id; break; } tankComponent10 = factoryStorage.tankPool[tankComponent10.nextTankId]; tankComponent11 = tankComponent10; } if (!tankComponent11.inputSwitch) { tankComponent11 = factoryStorage.tankPool[tankComponent11.lastTankId]; } bool flag4 = true; TankComponent tankComponent12 = factoryStorage.tankPool[tankComponent11.lastTankId]; if (((tankComponent11.id == __instance.id || tankComponent11.currentCount >= tankComponent11.fluidStorageCount) && !SpecialFluid.Contains(__instance.fluidId)) || !tankComponent12.outputSwitch) { flag4 = false; } if (flag4 && cargoTraffic.TryPickItemAtRear(__instance.belt3, __instance.fluidId, null) > 0) { if (factoryStorage.tankPool[tankComponent11.id].currentCount == 0) { factoryStorage.tankPool[tankComponent11.id].fluidId = __instance.fluidId; } TankComponent[] tankPool4 = factoryStorage.tankPool; int num8 = tankComponent11.id; tankPool4[num8].currentCount = tankPool4[num8].currentCount + 1; if (tankPool4[num8].currentCount > tankPool4[num8].fluidStorageCount) { tankPool4[num8].currentCount = tankPool4[num8].fluidStorageCount; } } } } } return(false); }
void MoveControl(TankComponent tank, InputComponent input, MoveComponent move, Transform transform, GameobjectComponent gameobjectComponent) { float spinSpeed = tank.spinSpeed; bool moveForward = InputSystem.GetHoldAction(input, "move_up"); bool moveBack = InputSystem.GetHoldAction(input, "move_down"); bool spinLeft = InputSystem.GetHoldAction(input, "move_left"); bool spinRight = InputSystem.GetHoldAction(input, "move_right"); move.needMove = false; if (moveForward || moveBack) { if (moveForward) { move.moveDirection = 1; } else if (moveBack) { move.moveDirection = -1; } move.needMove = true; spinSpeed /= 2; gameobjectComponent.animator.SetInteger("state", 1); if (tank.trackLeftAnimator != null && tank.trackRightAnimator != null) { tank.trackLeftAnimator.SetBool("move", true); tank.trackRightAnimator.SetBool("move", true); } } else { gameobjectComponent.animator.SetInteger("state", 0); if (tank.trackLeftAnimator != null && tank.trackRightAnimator != null) { tank.trackLeftAnimator.SetBool("move", false); tank.trackRightAnimator.SetBool("move", false); } } if (spinLeft) { transform.Rotate(new Vector3(0, 0, spinSpeed)); } else if (spinRight) { transform.Rotate(new Vector3(0, 0, -spinSpeed)); } BoxCollider2D collider = gameobjectComponent.collider; if (move.needMove == true) { Vector3 directionVec; if (move.moveDirection == 1) { directionVec = transform.up; } else { directionVec = -transform.up; } Vector3 nextPosition = transform.position + directionVec * move.moveSpeed * Time.fixedDeltaTime; if (move.collisionDetection == true) { collider.enabled = false; Collider2D otherCollider = Physics2D.OverlapBox(transform.position + directionVec * 35, new Vector2(40, 20), transform.rotation.eulerAngles.z); if (otherCollider != null && !otherCollider.tag.Equals("tree")) { nextPosition = transform.position; } } transform.position = nextPosition; if (collider.enabled == false) { collider.enabled = true; } } }