public RemotePlayerModel(ushort playerId) { // Spawn remote player model by cloning the player prefab and replacing local player script by remote player ones. string playerPrefabPath = LDB.players.Select(PLAYER_PROTO_ID).PrefabPath; if (playerPrefabPath != null) { PlayerTransform = Object.Instantiate(Resources.Load <Transform>(playerPrefabPath)); PlayerModelTransform = PlayerTransform.Find("Model"); // Remove local player components Object.Destroy(PlayerTransform.GetComponent <PlayerFootsteps>()); Object.Destroy(PlayerTransform.GetComponent <PlayerEffect>()); Object.Destroy(PlayerTransform.GetComponent <PlayerAudio>()); Object.Destroy(PlayerTransform.GetComponent <PlayerAnimator>()); Object.Destroy(PlayerTransform.GetComponent <PlayerController>()); PlayerTransform.GetComponent <Rigidbody>().isKinematic = true; // Add remote player components Movement = PlayerTransform.gameObject.AddComponent <RemotePlayerMovement>(); Animator = PlayerTransform.gameObject.AddComponent <RemotePlayerAnimation>(); Effects = PlayerTransform.gameObject.AddComponent <RemotePlayerEffects>(); } PlayerTransform.gameObject.name = $"Remote Player ({playerId})"; PlayerInstance = new Player(); MechaInstance = new Mecha(); AccessTools.Property(typeof(Player), "mecha").SetValue(PlayerInstance, MechaInstance, null); MechaInstance.Init(PlayerInstance); }
public void UpdateMech(Mecha destination) { destination.coreEnergyCap = coreEnergyCap; destination.corePowerGen = corePowerGen; destination.reactorPowerGen = reactorPowerGen; destination.walkPower = walkPower; destination.jumpEnergy = jumpEnergy; destination.thrustPowerPerAcc = thrustPowerPerAcc; destination.warpKeepingPowerPerSpeed = warpKeepingPowerPerSpeed; destination.warpStartPowerPerSpeed = warpStartPowerPerSpeed; destination.miningPower = miningPower; destination.replicatePower = replicatePower; destination.researchPower = researchPower; destination.droneEjectEnergy = droneEjectEnergy; destination.droneEnergyPerMeter = droneEnergyPerMeter; destination.coreLevel = coreLevel; destination.thrusterLevel = thrusterLevel; destination.miningSpeed = miningSpeed; destination.replicateSpeed = replicateSpeed; destination.walkSpeed = walkSpeed; destination.jumpSpeed = jumpSpeed; destination.maxSailSpeed = maxSailSpeed; destination.maxWarpSpeed = maxWarpSpeed; destination.buildArea = buildArea; destination.droneCount = droneCount; destination.droneSpeed = droneSpeed; destination.droneMovement = droneMovement; if (inventorySize > destination.player.package.size) { destination.player.package.SetSize(inventorySize); } }
public static void SetForNewGame_Postfix(Mecha __instance) { int dummyOut; __instance.coreEnergyCap = 30000000000; __instance.coreEnergy = 30000000000; __instance.corePowerGen = 5000000; __instance.reactorPowerGen = 20000000; __instance.coreLevel = 5; __instance.thrusterLevel = 5; __instance.maxSailSpeed = 2000f; __instance.maxWarpSpeed = 1000000f; __instance.walkSpeed = 25f; __instance.player.package.AddItemStacked(1803, 40, 1, out dummyOut); //add antimatter __instance.player.package.AddItemStacked(1501, 600, 1, out dummyOut); //add sails __instance.player.package.AddItemStacked(1503, 60, 1, out dummyOut); //add rockets __instance.player.package.AddItemStacked(2312, 10, 1, out dummyOut); //add launching silo __instance.player.package.AddItemStacked(2210, 10, 1, out dummyOut); //add artifical sun __instance.player.package.AddItemStacked(2311, 20, 1, out dummyOut); //add railgun __instance.player.package.AddItemStacked(2001, 600, 1, out dummyOut); //add MK3 belts __instance.player.package.AddItemStacked(2002, 600, 1, out dummyOut); //add MK3 belts __instance.player.package.AddItemStacked(2003, 600, 1, out dummyOut); //add MK3 belts __instance.player.package.AddItemStacked(2013, 100, 1, out dummyOut); //add MK3 inserters __instance.player.package.AddItemStacked(2212, 20, 1, out dummyOut); //add satelite sub-station }
public void UpdateMech(Mecha destination) { destination.coreEnergyCap = this.coreEnergyCap; destination.corePowerGen = this.corePowerGen; destination.reactorPowerGen = this.reactorPowerGen; destination.walkPower = this.walkPower; destination.jumpEnergy = this.jumpEnergy; destination.thrustPowerPerAcc = this.thrustPowerPerAcc; destination.warpKeepingPowerPerSpeed = this.warpKeepingPowerPerSpeed; destination.warpStartPowerPerSpeed = this.warpStartPowerPerSpeed; destination.miningPower = this.miningPower; destination.replicatePower = this.replicatePower; destination.researchPower = this.researchPower; destination.droneEjectEnergy = this.droneEjectEnergy; destination.droneEnergyPerMeter = this.droneEnergyPerMeter; destination.coreLevel = this.coreLevel; destination.thrusterLevel = this.thrusterLevel; destination.miningSpeed = this.miningSpeed; destination.replicateSpeed = this.replicateSpeed; destination.walkSpeed = this.walkSpeed; destination.jumpSpeed = this.jumpSpeed; destination.maxSailSpeed = this.maxSailSpeed; destination.maxWarpSpeed = this.maxWarpSpeed; destination.buildArea = this.buildArea; destination.droneCount = this.droneCount; destination.droneSpeed = this.droneSpeed; destination.droneMovement = this.droneMovement; }
static bool Prefix(ref Mecha __instance) { Debug.Log("Restoring values for saving"); __instance.replicateSpeed = FreeReplicatorMode.originalReplicateSpeed; __instance.replicatePower = FreeReplicatorMode.originalReplicatePower; return(true); }
public static void GameTick_Postfix(Mecha __instance, long time, float dt) { if (SimulatedWorld.Initialized) { SimulatedWorld.OnDronesGameTick(time, dt); } }
public void Initialize(Mecha mecha) { if (mecha == null) { Clean(); } else { if (targetMecha != mecha) { Clean(); SliderContainer.gameObject.SetActive(true); targetMecha = mecha; LifeSlider = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.HUDSlider].AllocateGameObject <HUDSlider>(SliderContainer); LifeSlider.Initialize(2, LifeSliderColor, out targetMecha.OnLifeChange); PowerSlider = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.HUDSlider].AllocateGameObject <HUDSlider>(SliderContainer); PowerSlider.Initialize(2, PowerSliderColor, out targetMecha.OnPowerChange); MechaNameText.text = mecha.MechaInfo.MechaName; LifeSlider.SetValue(mecha.M_LeftLife, mecha.M_TotalLife); PowerSlider.SetValue(mecha.M_LeftPower, mecha.M_TotalPower); targetMecha.RefreshHUDPanelCoreLifeSliderCount = RefreshCoreLifeSliders; targetMecha.RefreshHUDPanelCoreLifeSliderCount(); } } }
public PlayerTechBonuses(Mecha source) { coreEnergyCap = source.coreEnergyCap; corePowerGen = source.corePowerGen; reactorPowerGen = source.reactorPowerGen; walkPower = source.walkPower; jumpEnergy = source.jumpEnergy; thrustPowerPerAcc = source.thrustPowerPerAcc; warpKeepingPowerPerSpeed = source.warpKeepingPowerPerSpeed; warpStartPowerPerSpeed = source.warpStartPowerPerSpeed; miningPower = source.miningPower; replicatePower = source.replicatePower; researchPower = source.researchPower; droneEjectEnergy = source.droneEjectEnergy; droneEnergyPerMeter = source.droneEnergyPerMeter; coreLevel = source.coreLevel; thrusterLevel = source.thrusterLevel; miningSpeed = source.miningSpeed; replicateSpeed = source.replicateSpeed; walkSpeed = source.walkSpeed; jumpSpeed = source.jumpSpeed; maxSailSpeed = source.maxSailSpeed; maxWarpSpeed = source.maxWarpSpeed; buildArea = source.buildArea; droneCount = source.droneCount; droneSpeed = source.droneSpeed; droneMovement = source.droneMovement; inventorySize = source.player.package.size; }
public void AddEnemy() { Mecha EnemyMecha = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.Mecha].AllocateGameObject <Mecha>(MechaContainer); List <MechaComponentInfo> enemyComponentInfos = new List <MechaComponentInfo>(); for (int i = -4; i <= 4; i++) { for (int j = -6; j <= 6; j++) { MechaComponentInfo mci; if (i == 0 && j == 0) { mci = new MechaComponentInfo(MechaComponentType.Core, new GridPos(i, j, GridPos.Orientation.Up), 500, 0); } else { mci = new MechaComponentInfo((MechaComponentType)Random.Range(1, Enum.GetNames(typeof(MechaComponentType)).Length), new GridPos(i, j, GridPos.Orientation.Up), 50, 5); } enemyComponentInfos.Add(mci); } } EnemyMecha.Initialize(new MechaInfo("Junk Mecha", MechaType.Enemy, enemyComponentInfos)); EnemyMecha.transform.position = new Vector3(10, 0, 10); EnemyMechas.Add(EnemyMecha); }
public PlayerTechBonuses(Mecha source) { this.coreEnergyCap = source.coreEnergyCap; this.corePowerGen = source.corePowerGen; this.reactorPowerGen = source.reactorPowerGen; this.walkPower = source.walkPower; this.jumpEnergy = source.jumpEnergy; this.thrustPowerPerAcc = source.thrustPowerPerAcc; this.warpKeepingPowerPerSpeed = source.warpKeepingPowerPerSpeed; this.warpStartPowerPerSpeed = source.warpStartPowerPerSpeed; this.miningPower = source.miningPower; this.replicatePower = source.replicatePower; this.researchPower = source.researchPower; this.droneEjectEnergy = source.droneEjectEnergy; this.droneEnergyPerMeter = source.droneEnergyPerMeter; this.coreLevel = source.coreLevel; this.thrusterLevel = source.thrusterLevel; this.miningSpeed = source.miningSpeed; this.replicateSpeed = source.replicateSpeed; this.walkSpeed = source.walkSpeed; this.jumpSpeed = source.jumpSpeed; this.maxSailSpeed = source.maxSailSpeed; this.maxWarpSpeed = source.maxWarpSpeed; this.buildArea = source.buildArea; this.droneCount = source.droneCount; this.droneSpeed = source.droneSpeed; this.droneMovement = source.droneMovement; }
public static bool UseEnergyPrefix(ref Mecha __instance, ref float __result) { __result = 1f; __instance.coreEnergy = __instance.coreEnergyCap; return(false); }
void Start() { Destroy(this.gameObject, lifeTime); target = GameObject.FindGameObjectWithTag("Player").GetComponent <Mecha>(); // Vector3 pos = new Vector3(Range.Random(min, max), Range,Random(min, max)); totalDistanceFromTarget = GetDistanceFromTarget(); timer = 0; speed = totalDistanceFromTarget.x / lifeTime; }
public void AddUnit(Mecha mecha) { if (units == null) { units = new List <Mecha>(); } units.Add(mecha); }
static void Postfix(ref Mecha __instance) { FreeReplicatorMode.originalReplicateSpeed = __instance.replicateSpeed; FreeReplicatorMode.originalReplicatePower = __instance.replicatePower; Debug.Log("Loaded mecha. Replicator speed was: " + __instance.replicateSpeed); __instance.replicateSpeed = 10.0f; Debug.Log("Replicator speed is now : " + __instance.replicateSpeed); Debug.Log("Removing energy cost for replication" + __instance.replicateSpeed); __instance.replicatePower = 0.0; }
public static bool Mecha_GenerateEnergy_Prefix(Mecha __instance, double dt) { // some players managed to break the fuel chamber on clients. // the game thought there is still fuel burning while not adding energy to the mecha and preventing new fuel from beeing added. // this checks for this corner case and resets the reactor energy to 0 (empty fuel chamber as displayed to the player) if (!LocalPlayer.IsMasterClient && __instance.reactorEnergy > 0 && __instance.reactorItemId == 0) { __instance.reactorEnergy = 0; } return(true); }
protected virtual void Start() { Health health = GetComponent <Health>(); mech = health._mech; //print(gameObject.name + " is a " + mech.mechType); specialCooldown = mech.specialCooldown; specialUseTimeLimit = mech.specialUseTimeLimit; }
public static void Postfix(Mecha __instance) { if (FreeFoundationsFreeSoilPlugin.buildrangeEnabled) { __instance.buildArea = (float)FreeFoundationsFreeSoilPlugin.buildrange; } else { __instance.buildArea = 80f; } }
public void Serialize(NetDataWriter writer) { writer.Put(Username); writer.Put(PlayerId); writer.Put(LocalPlanetId); MechaColor.Serialize(writer); LocalPlanetPosition.Serialize(writer); UPosition.Serialize(writer); Rotation.Serialize(writer); BodyRotation.Serialize(writer); Mecha.Serialize(writer); }
void Start() { target = GameObject.FindGameObjectWithTag("Player").GetComponent <Mecha> (); anim = GetComponent <Animator> (); SetSpeed(GetInitialSpeed()); isEnraged = false; //enrageHpThreshold = (GetHP() * lives) / 2 ; // Enrage HP //ReceiveDamage (1000); curAttackState = AttackState.CHECK; prevAttackState = AttackState.CHECK; //anim.SetLayerWeight(1, 1); }
protected override void OnStart() { // Load data UnityFactory.factory.LoadDragonBonesData("mecha_1502b/mecha_1502b_ske"); UnityFactory.factory.LoadTextureAtlasData("mecha_1502b/mecha_1502b_tex"); UnityFactory.factory.LoadDragonBonesData("skin_1502b/skin_1502b_ske"); UnityFactory.factory.LoadTextureAtlasData("skin_1502b/skin_1502b_tex"); UnityFactory.factory.LoadDragonBonesData("weapon_1000/weapon_1000_ske"); UnityFactory.factory.LoadTextureAtlasData("weapon_1000/weapon_1000_tex"); // this._player = new Mecha(); }
public override void PoolRecycle() { ParentMecha = null; MechaHitBoxRoot.SetInBattle(false); base.PoolRecycle(); foreach (FX lighteningFX in lighteningFXs) { lighteningFX.PoolRecycle(); } lighteningFXs.Clear(); isReturningToBag = false; }
private void Initialize(MechaComponentInfo mechaComponentInfo, Mecha parentMecha) { IsDead = false; UnlinkAllBuffs(); MechaComponentInfo = mechaComponentInfo; GridPos.ApplyGridPosToLocalTrans(mechaComponentInfo.GridPos, transform, GameManager.GridSize); RefreshOccupiedGridPositions(); ParentMecha = parentMecha; M_TotalLife = mechaComponentInfo.TotalLife; M_LeftLife = mechaComponentInfo.TotalLife; MechaHitBoxRoot.SetInBattle(true); Child_Initialize(); }
public void EnviarMecha(Mecha mechaAEnviar) { string mecha; mecha = "M"; //mecha += mechaAEnviar.diametro.ToString(); mecha += mechaAEnviar.diametroStr; mecha = mecha.Replace(",", "."); while (mecha.Length < 6) { mecha += "0"; } Enviar(mecha); }
public void Serialize(INetDataWriter writer) { writer.Put(Username); writer.Put(PlayerId); writer.Put(LocalPlanetId); writer.Put(MechaColors?.Length ?? 0); for (int i = 0; i < (MechaColors?.Length ?? 0); i++) { MechaColors[i].Serialize(writer); } LocalPlanetPosition.Serialize(writer); UPosition.Serialize(writer); Rotation.Serialize(writer); BodyRotation.Serialize(writer); Mecha.Serialize(writer); writer.Put(Appearance != null); if (Appearance != null) { using (MemoryStream ms = new MemoryStream()) { using (BinaryWriter wr = new BinaryWriter(ms)) { Appearance.Export(wr); } byte[] export = ms.ToArray(); writer.Put(export.Length); writer.Put(export); } } writer.Put(DIYAppearance != null); if (DIYAppearance != null) { using (MemoryStream ms = new MemoryStream()) { using (BinaryWriter wr = new BinaryWriter(ms)) { DIYAppearance.Export(wr); } byte[] export = ms.ToArray(); writer.Put(export.Length); writer.Put(export); } } writer.Put(DIYItemId.Length); for (int i = 0; i < DIYItemId.Length; i++) { writer.Put(DIYItemId[i]); writer.Put(DIYItemValue[i]); } }
public void GetController <T>(T creator) where T : Creator { if (creator.Player == Creator.PlayerHalf.Orga) { Orga = creator; Orga.AssignGamepad(GamePadController.GamePadOne); return; } if (creator.Player == Creator.PlayerHalf.Mecha) { Mecha = creator; Mecha.AssignGamepad(GamePadController.GamePadTwo); } }
public static IEnumerable <CodeInstruction> SailPanelPath(IEnumerable <CodeInstruction> instructions) { MethodInfo getSpeedMethod = AccessTools.Method(typeof(MechaMod), nameof(getMechaMaxSailSpeed)); Mecha mecha = GameMain.data?.mainPlayer?.mecha; List <CodeInstruction> codes = instructions.ToList(); foreach (CodeInstruction code in codes) { if (code.opcode == OpCodes.Ldc_R8 && (double)code.operand == 2000) { yield return(new CodeInstruction(OpCodes.Call, getSpeedMethod)); } else { yield return(code); } } }
void Update() { Ray ray = GameManager.Instance.MainCamera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out RaycastHit hit, 1000f, GameManager.Instance.LayerMask_ComponentHitBox)) { if (hit.collider) { HitBox hitBox = hit.collider.GetComponent <HitBox>(); Mecha mecha = hitBox?.ParentHitBoxRoot?.MechaComponentBase?.ParentMecha; if (mecha && mecha.MechaInfo.MechaType == MechaType.Enemy) { HUDPanel.LoadEnemyMech(mecha); } } else { HUDPanel.LoadEnemyMech(null); } }
public override void OnStateEnter() { //Debug.Log(agent.gameObject.name + " is entered Retreat State"); navAgent = agent.GetComponent <NavMeshAgent>(); thisAgentShootingScript = agent.GetComponent <EnemyShooting>(); health = agent.GetComponent <Health>(); doubleStats = agent.GetComponent <DoubleStatsSpecial>(); if (doubleStats != null && doubleStats._areStatsBuffed) { defaultAiSpeed = agent._mech.fowardMoveSpeed * 2; } else { defaultAiSpeed = agent._mech.fowardMoveSpeed; } navAgent.SetDestination(agent.transform.position); mech = agent._mech; enemyPos = health._myAttacker; if (enemyPos != null) { if (enemyPos.CompareTag("Player")) { playerShooting = enemyPos.GetComponent <PlayerShooting>(); minDistanceFromEnemyPos = playerShooting._playerShootingRange; } else if (enemyPos.CompareTag("Enemy") && !enemyPos.CompareTag("Non-playables")) { aiAttackerShootingScript = enemyPos.GetComponent <EnemyShooting>(); minDistanceFromEnemyPos = aiAttackerShootingScript.getBreakContactRange; } else { Debug.LogError(agent.gameObject.name + "'s " + "attacker is null or unknown!"); } } }
public void Clean() { if (targetMecha) { targetMecha.RefreshHUDPanelCoreLifeSliderCount = null; targetMecha.OnLifeChange = null; targetMecha.OnPowerChange = null; targetMecha = null; } foreach (HUDSlider coreHudSlider in Core_HUDSliders) { coreHudSlider.PoolRecycle(); } Core_HUDSliders.Clear(); LifeSlider?.PoolRecycle(); PowerSlider?.PoolRecycle(); MechaNameText.text = ""; SliderContainer.gameObject.SetActive(false); }
public RemotePlayerModel(ushort playerId, string username) { // Spawn remote player model by cloning the player prefab and replacing local player script by remote player ones. string playerPrefabPath = LDB.players.Select(PLAYER_PROTO_ID).PrefabPath; if (playerPrefabPath != null) { PlayerTransform = Object.Instantiate(Resources.Load <Transform>(playerPrefabPath)); PlayerModelTransform = PlayerTransform.Find("Model"); // Remove local player components Object.Destroy(PlayerTransform.GetComponent <PlayerFootsteps>()); Object.Destroy(PlayerTransform.GetComponent <PlayerEffect>()); Object.Destroy(PlayerTransform.GetComponent <PlayerAudio>()); Object.Destroy(PlayerTransform.GetComponent <PlayerAnimator>()); Object.Destroy(PlayerTransform.GetComponent <PlayerController>()); PlayerTransform.GetComponent <Rigidbody>().isKinematic = true; // Add remote player components Movement = PlayerTransform.gameObject.AddComponent <RemotePlayerMovement>(); Animator = PlayerTransform.gameObject.AddComponent <RemotePlayerAnimation>(); Effects = PlayerTransform.gameObject.AddComponent <RemotePlayerEffects>(); } PlayerTransform.gameObject.name = $"Remote Player ({playerId})"; PlayerInstance = new global::Player(); MechaInstance = new Mecha(); AccessTools.Property(typeof(global::Player), "mecha").SetValue(PlayerInstance, MechaInstance, null); MechaInstance.Init(PlayerInstance); //Fix MechaDroneRenderers AccessTools.Field(typeof(MechaDroneRenderer), "mat_0").SetValue(MechaInstance.droneRenderer, new Material(Configs.builtin.mechaDroneMat.shader)); Material mat = (Material)AccessTools.Field(typeof(MechaDroneRenderer), "mat_0").GetValue(MechaInstance.droneRenderer); MethodInvoker.GetHandler(AccessTools.Method(typeof(Material), "CopyPropertiesFromMaterial", new System.Type[] { typeof(Material) })).Invoke(mat, Configs.builtin.mechaDroneMat); PlayerId = playerId; Username = username; }
public AutoCannon(Mecha mecha) : base(mecha) { Description = "AutoCannon 30"; }
public MechaWeapon(Mecha mecha) { _mecha = mecha; }