public Item ToItem() { if (Amount == 0) { return(null); } Item item = ItemManager.CreateByItemID(ID, Amount, Skin); item.position = Position; if (IsBlueprint) { item.blueprintTarget = BlueprintTarget; return(item); } item.fuel = Fuel; item.condition = Condition; if (MaxCondition != -1) { item.maxCondition = MaxCondition; } if (Contents != null) { foreach (var contentItem in Contents) { contentItem.ToItem().MoveToContainer(item.contents); } } else { item.contents = null; } BaseProjectile.Magazine magazine = item.GetHeldEntity()?.GetComponent <BaseProjectile>()?.primaryMagazine; FlameThrower flameThrower = item.GetHeldEntity()?.GetComponent <FlameThrower>(); if (magazine != null) { magazine.contents = Ammo; magazine.ammoType = ItemManager.FindItemDefinition(AmmoType); } if (flameThrower != null) { flameThrower.ammo = FlameFuel; } if (item.instanceData != null) { item.instanceData.dataInt = DataInt; } item.text = Text; return(item); }
public Item ToItem() { Item item = ItemManager.CreateByItemID(ID, Amount, Skin); BaseProjectile.Magazine magazine = item.GetHeldEntity()?.GetComponent <BaseProjectile>()?.primaryMagazine; FlameThrower flameThrower = item.GetHeldEntity()?.GetComponent <FlameThrower>(); item.fuel = Fuel; item.condition = Condition; if (Contents != null) { foreach (var contentItem in Contents) { contentItem.ToItem().MoveToContainer(item.contents); } } else { item.contents = null; } if (magazine != null) { magazine.contents = Ammo; magazine.ammoType = ItemManager.FindItemDefinition(AmmoType); } if (flameThrower != null) { flameThrower.ammo = FlameFuel; } return(item); }
private void BuySelectedTower() { AudioManager.instance.PlaySfx(build, 3); GameObject tower = Instantiate(towerPrefabs[selectedTowerType].gameObject, towersParent); tower.transform.position = new Vector3(previewTower.transform.position.x, previewTower.transform.position.y, 0f); Tower t = tower.GetComponent <Tower>(); if (t.animator != null) { t.animator.speed = 1 + (UpgradeManager._instance.fireRateUpgradeLevel * UpgradeManager._instance.fireRateUpgrade); } if (t.GetType().Name == "FlameThrower") { FlameThrower ft = t.GetComponent <FlameThrower>(); ft.flameCollider.size = new Vector2(ft.initialSizeX * (1f + (UpgradeManager._instance.flamethrowerRangeUpgradeLevel * UpgradeManager._instance.flamethrowerRangeUpgrade)), ft.flameCollider.size.y); ft.flameCollider.offset = new Vector2(ft.initialOffsetX * (1f + (UpgradeManager._instance.flamethrowerRangeUpgradeLevel * UpgradeManager._instance.flamethrowerRangeUpgrade * 0.75f)), ft.flameCollider.offset.y); // 0.75f otherwise the collider moves away from the flamethrower sprite var fpsm = ft.flameParticleSystem.main; fpsm.startSpeedMultiplier = ft.initialStartSpeed * (1f + (UpgradeManager._instance.flamethrowerRangeUpgradeLevel * UpgradeManager._instance.flamethrowerRangeUpgrade)); } towers.Add(t); GameManager._instance.Spend(Mathf.FloorToInt(towerPrefabs[selectedTowerType].cost * Mathf.Pow(1.5f, towersBought[selectedTowerType]))); towersBought[selectedTowerType]++; UpdateTowersButtonText(); }
Item BuildItem(SavedItem sItem) { if (sItem.amount < 1) { sItem.amount = 1; } Item item = null; item = ItemManager.CreateByItemID(sItem.itemid, sItem.amount, sItem.skinid); if (item.hasCondition) { item.condition = sItem.condition; item.maxCondition = sItem.maxcondition; item.busyTime = sItem.busyTime; } if (sItem.name != null) { item.name = sItem.name; } if (sItem.OnFire) { item.SetFlag(global::Item.Flag.OnFire, true); } FlameThrower flameThrower = item.GetHeldEntity()?.GetComponent <FlameThrower>(); if (flameThrower) { flameThrower.ammo = sItem.flamefuel; } return(item); }
static void Main(string[] args) { IGolpe megaPunch = new MegaPunch(); IGolpe flameThrower = new FlameThrower(); IGolpe bubbleBeam = new BubbleBeam(); IGolpe scratch = new Scratch(); IGolpe leechSeed = new LeechSeed(); Pokemon charmander = new TipoFogo("Charmander", 5); Pokemon bulbasaur = new TipoPlanta("Bulbasaur", 5); Pokemon squirtle = new TipoAgua("Squirtle", 5); Pokemon pikachu = new TipoEletrico("Pikachu", 5); Pokemon meowth = new TipoNormal("Meowth", 5); List <Pokemon> especies = new List <Pokemon>() { charmander, bulbasaur, squirtle, pikachu, meowth }; List <IGolpe> golpes = new List <IGolpe>() { megaPunch, flameThrower, bubbleBeam, scratch, leechSeed }; foreach (Pokemon pokemon in especies) { foreach (IGolpe golpe in golpes) { pokemon._golpe = golpe; Console.WriteLine("{0} no nĂvel {1} utilizando {2} causa dano de {3}HP", pokemon._especie, pokemon._nivel, pokemon._golpe._nomeGolpe, pokemon.Ataque()); } } }
protected override void OnAwake() { bomb = Resources.Load <Bomb>("Objects/Bomb"); cardReset = Resources.Load <CardReset>("Objects/CardReset"); changeCardPosition = Resources.Load <ChangeCardPosition>("Objects/ChangeCardPosition"); weapon = Resources.Load <Weapon>("Objects/Weapon"); flameThrower = Resources.Load <FlameThrower>("Objects/Flame"); //Trap thorn = Resources.Load <Thorn>(PATH_TRAP + "Thorn"); //Trap //Coin goldCoin = Resources.Load <Coin>(PATH_COIN + "GoldCoin"); //Coin //Monster ghost = Resources.Load <Monster>(PATH_MONSTER + "Ghost"); slime = Resources.Load <Slime>(PATH_MONSTER + "Slime"); imp = Resources.Load <Imp>(PATH_MONSTER + "Imp"); //Monster //Potion blackPotion = Resources.Load <BlackPotion>(PATH_POTION + "BlackPotion"); bluePotion = Resources.Load <BluePotion>(PATH_POTION + "BluePotion"); pinkPotion = Resources.Load <PinkPotion>(PATH_POTION + "PinkPotion"); purplePotion = Resources.Load <PurplePotion>(PATH_POTION + "PurplePotion"); redPotion = Resources.Load <RedPotion>(PATH_POTION + "RedPotion"); yellowPotion = Resources.Load <YellowPotion>(PATH_POTION + "Yellowpotion"); //Potion }
private void OnFlameThrowerBurn(FlameThrower flameThrower, BaseEntity baseEntity) { var flame = baseEntity.gameObject.AddComponent <Flame>(); flame.Source = Flame.FlameSource.Flamethrower; flame.SourceEntity = flameThrower; flame.Initiator = flameThrower.GetOwnerPlayer(); }
public void AddFlamethrower() { _flameThrower = GetComponent <FlameThrower>(); weaponElement = _flameThrower.WeaponElement(); _selectFlameThrower = _weaponAmount; _weapon = Weapon.FLAMETHROWER; SetWeapons(_weapon); }
SavedItem SaveItem(Item item) { SavedItem iItem = new SavedItem { shortname = item.info?.shortname, amount = item.amount, mods = new List <SavedItem>(), skinid = item.skin }; if (item.info == null) { return(iItem); } iItem.itemid = item.info.itemid; iItem.weapon = false; if (item.hasCondition) { iItem.condition = item.condition; iItem.maxcondition = item.maxCondition; } FlameThrower flameThrower = item.GetHeldEntity()?.GetComponent <FlameThrower>(); if (flameThrower != null) { iItem.flamefuel = flameThrower.ammo; } if (item.info.category.ToString() != "Weapon") { return(iItem); } BaseProjectile weapon = item.GetHeldEntity() as BaseProjectile; if (weapon == null) { return(iItem); } if (weapon.primaryMagazine == null) { return(iItem); } iItem.ammoamount = weapon.primaryMagazine.contents; iItem.ammotype = weapon.primaryMagazine.ammoType.shortname; iItem.weapon = true; if (item.contents != null) { foreach (var mod in item.contents.itemList) { if (mod.info.itemid != 0) { iItem.mods.Add(SaveItem(mod)); } } } return(iItem); }
public void ReturnFlameThrower(FlameThrower card) { if (card.gameObject.activeSelf) { card.gameObject.SetActive(false); } card.transform.SetParent(_tr_FlameThrower); _stack_FlameThrower.Push(card); }
public void Stop() { // check if weapon is a flamethrower FlameThrower flamethrower = GetComponentInChildren <FlameThrower>(); if (flamethrower != null) { flamethrower.StopFiring(); } }
public void Shoot() { if (Time.time - lastShotOnTime > shootDelay && ammo > 0) { // Create the projectile Vector3 pos = shootPos.position; Quaternion rot = shootPos.rotation; // check if weapon has a projectile or not if (projectilePrefab != null) { GameObject projectile = Instantiate(projectilePrefab, pos, rot); Rigidbody projectileRb = projectile.AddComponent <Rigidbody>(); if (muzzleFlashPrefab != null) { GameObject muzzle = Instantiate(muzzleFlashPrefab, pos, rot); muzzle.transform.SetParent(transform, false); muzzle.transform.localPosition = shootPos.localPosition; muzzle.transform.forward = shootPos.forward; Destroy(muzzle, 0.3f); } // check if weapon is a grenade if (projectile.GetComponent <Explosion>() != null) { projectile.GetComponent <Explosion>().SetHolder(holder); } // Apply force to projectile to throw it projectileRb.AddForce(transform.forward * projectileForce); } else { // check if weapon is a laser Laser laser = GetComponentInChildren <Laser>(); if (laser != null) { laser.Fire(); } // check if weapon is a flamethrower FlameThrower flamethrower = GetComponentInChildren <FlameThrower>(); if (flamethrower != null) { flamethrower.Fire(); } } ammo--; lastShotOnTime = Time.time; AkSoundEngine.PostEvent("Weapon_Fire", gameObject); } }
public void WeaponPowerIsFifty() { // Arrange var weapon = new FlameThrower(); // Act var power = weapon.Power(); // Assert Assert.Equal(50, power); }
private void MakeFlameThrower(int count) { for (int i = 0; i < count; i++) { FlameThrower newFlameThrower = Instantiate(DataManager.instance.flameThrower); newFlameThrower.gameObject.SetActive(false); newFlameThrower.transform.SetParent(_tr_FlameThrower); _stack_FlameThrower.Push(newFlameThrower); } }
public void CausedIsThreeHundred() { // Arrange var weapon = new FlameThrower(); // Act var damage = weapon.Damage(); // Assert Assert.Equal(300, damage); }
public static RustItem fromItem(Item item, string container) { RustItem iItem = new RustItem { shortname = item.info?.shortname, amount = item.amount, mods = new List <RustItem>(), container = container, skinid = item.skin }; if (item.info == null) { return(iItem); } iItem.itemid = item.info.itemid; iItem.weapon = false; if (item.hasCondition) { iItem.condition = item.condition; iItem.maxCondition = item.maxCondition; } FlameThrower flameThrower = item.GetHeldEntity()?.GetComponent <FlameThrower>(); if (flameThrower != null) { iItem.flamefuel = flameThrower.ammo; } BaseProjectile weapon = item.GetHeldEntity() as BaseProjectile; if (weapon == null) { return(iItem); } if (weapon.primaryMagazine == null) { return(iItem); } iItem.ammoamount = weapon.primaryMagazine.contents; iItem.ammotype = weapon.primaryMagazine.ammoType.shortname; iItem.weapon = true; if (item.contents != null) { foreach (var mod in item.contents.itemList) { if (mod.info.itemid != 0) { iItem.mods.Add(fromItem(mod, "noun")); } } } return(iItem); }
public void UpdateFlamethrowerRange() { foreach (Tower tower in towers) { if (tower.GetType().Name == "FlameThrower") { FlameThrower ft = tower.GetComponent <FlameThrower>(); ft.flameCollider.size = new Vector2(ft.initialSizeX * (1f + (UpgradeManager._instance.flamethrowerRangeUpgradeLevel * UpgradeManager._instance.flamethrowerRangeUpgrade)), ft.flameCollider.size.y); ft.flameCollider.offset = new Vector2(ft.initialOffsetX * (1f + (UpgradeManager._instance.flamethrowerRangeUpgradeLevel * UpgradeManager._instance.flamethrowerRangeUpgrade * 0.75f)), ft.flameCollider.offset.y); // 0.75f otherwise the collider moves away from the flamethrower sprite var fpsm = ft.flameParticleSystem.main; fpsm.startSpeedMultiplier = ft.initialStartSpeed * (1f + (UpgradeManager._instance.flamethrowerRangeUpgradeLevel * UpgradeManager._instance.flamethrowerRangeUpgrade)); } } }
public void Initialize() { player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>(); GM = GameObject.FindGameObjectWithTag("Managers").GetComponent <GameManager>(); laser = GetComponentInChildren <LaserGun>(); flameThrower = GetComponentInChildren <FlameThrower>(); hJump = GetComponentInChildren <HyperJump>(); hDash = GetComponentInChildren <HyperDash>(); mLauncher = GetComponentInChildren <MisileLauncher>(); absorb = GetComponentInChildren <Absorb>(); laser.Initialize(); flameThrower.Initialize(); hJump.Initialize(); hDash.Initialize(); mLauncher.Initialize(); absorb.Initialize(); }
public Pyro() { _weapon1 = new FlameThrower(); _weapon2 = new PyroLauncher(); _weapon3 = new Shotgun(); _weapon4 = new Axe(); _gren1 = Ammunition.FragGrenade; _gren2 = Ammunition.NapalmGrenade; _health = 100; _armour = 150; _maxShells = 50; _maxNails = 50; _maxRockets = 60; _maxCells = 200; _maxGren1 = 4; _maxGren2 = 4; }
private void TowerSwitchInput() { if (previewTower != null) { if (input.KeyPressed(Keys.D1)) { previewTower = new FlameThrower(selectedTower.X, selectedTower.Y, previewTower.HotkeyNumber); } else if (input.KeyPressed(Keys.D2)) { previewTower = new Shotgun(selectedTower.X, selectedTower.Y, previewTower.HotkeyNumber); } else if (input.KeyPressed(Keys.D3)) { previewTower = new Sniper(selectedTower.X, selectedTower.Y, previewTower.HotkeyNumber); } } }
public void AddFireStack(FlameThrower f) { bool added = false; for (int i = 0; i < _stackFlamethrowers.Count; i++) { if (_stackFlamethrowers[i].FlameThrower == f) { FireStack fs = new FireStack(f, new CoolDownTimer(f.BurnTime)); fs.FireTimer.Reset(); _stackFlamethrowers[i] = fs; added = true; } } if (!added) { FireStack fs = new FireStack(f, new CoolDownTimer(f.BurnTime)); fs.FireTimer.Reset(); _stackFlamethrowers.Add(fs); } }
public void GiveRankWeapon(Item item) { RankWeapon = item; Player.GiveItem(item, BaseEntity.GiveItemReason.PickedUp); BaseProjectile baseProjectile = item.GetHeldEntity() as BaseProjectile; if (baseProjectile != null) { Item ammo = ItemManager.Create(baseProjectile.primaryMagazine.ammoType, baseProjectile.primaryMagazine.capacity * 5); Player.GiveItem(ammo); } FlameThrower flameThrower = item.GetHeldEntity() as FlameThrower; if (flameThrower != null) { Item ammo = ItemManager.CreateByName("lowgradefuel", 1500); Player.GiveItem(ammo); } }
Item BuildItem(RustItem sItem, ulong skin = ulong.MaxValue) { if (sItem.amount < 1) { sItem.amount = 1; } Item item = ItemManager.CreateByItemID(sItem.itemid, sItem.amount, skin != ulong.MaxValue ? skin : sItem.skinid); if (item.hasCondition) { item.condition = sItem.condition; item.maxCondition = sItem.maxCondition; } FlameThrower flameThrower = item.GetHeldEntity()?.GetComponent <FlameThrower>(); if (flameThrower) { flameThrower.ammo = sItem.flamefuel; } return(item); }
private object CanStackItem(Item item, Item targetItem) { if (item.info.shortname != targetItem.info.shortname) { return(null); } if (item.contents != targetItem.contents) { return(false); } FlameThrower flamethrower = item.GetHeldEntity() as FlameThrower; if (flamethrower != null) { if (flamethrower.ammo != (targetItem.GetHeldEntity() as FlameThrower).ammo) { return(false); } } return(null); }
private void AddTower(int x, int y, Utility.TowerType type, int HotKeyNumber) { Tower tower = null; switch (type) { case Utility.TowerType.FlameThrower: tower = new FlameThrower(x, y, HotKeyNumber); break; case Utility.TowerType.Sniper: tower = new Sniper(x, y, HotKeyNumber); break; case Utility.TowerType.Shotgun: tower = new Shotgun(x, y, HotKeyNumber); break; default: throw new ArgumentException("invalid tower type: " + type); } Utility.TowerList.Add(tower); }
// Use this for initialization void Start() { flameThrower = GetComponentInParent <FlameThrower>(); }
public FireStack(FlameThrower flameThrower, CoolDownTimer fireTimer) { FlameThrower = flameThrower; FireTimer = fireTimer; }
private object CanStackItem(Item item, Item targetItem) { if (item.GetOwnerPlayer().IsUnityNull()) { return(null); } if ( item == targetItem || item.info.stackable <= 1 || item.info.itemid != targetItem.info.itemid || !item.IsValid() || (item.IsBlueprint() && item.blueprintTarget != targetItem.blueprintTarget) || (item.hasCondition && (item.condition != item.info.condition.max || targetItem.condition != targetItem.info.condition.max)) ) { return(false); } if (item.info.amountType == ItemDefinition.AmountType.Genetics || targetItem.info.amountType == ItemDefinition.AmountType.Genetics) { if ((item.instanceData?.dataInt ?? -1) != (targetItem.instanceData?.dataInt ?? -1)) { return(false); } } // Return contents if (targetItem.contents?.itemList.Count > 0) { foreach (Item containedItem in targetItem.contents.itemList) { item.parent.playerOwner.GiveItem(ItemManager.CreateByItemID(containedItem.info.itemid, containedItem.amount)); } } if (_config.DisableDupeFixAndLeaveWeaponMagsAlone) { return(null); } BaseProjectile.Magazine itemMag = targetItem.GetHeldEntity()?.GetComponent <BaseProjectile>()?.primaryMagazine; // Return ammo if (itemMag != null) { if (itemMag.contents > 0) { item.GetOwnerPlayer().GiveItem(ItemManager.CreateByItemID(itemMag.ammoType.itemid, itemMag.contents)); } } if (targetItem.GetHeldEntity() is FlameThrower) { FlameThrower flameThrower = targetItem.GetHeldEntity().GetComponent <FlameThrower>(); if (flameThrower.ammo > 0) { item.GetOwnerPlayer().GiveItem(ItemManager.CreateByItemID(flameThrower.fuelType.itemid, flameThrower.ammo)); } } if (targetItem.GetHeldEntity() is Chainsaw) { Chainsaw chainsaw = targetItem.GetHeldEntity().GetComponent <Chainsaw>(); if (chainsaw.ammo > 0) { item.GetOwnerPlayer().GiveItem(ItemManager.CreateByItemID(chainsaw.fuelType.itemid, chainsaw.ammo)); } } return(null); }
private void parseAction(string s) { string[] pairs = s.Split('$'); if (pairs.Length > 1) { string sig = pairs[1].Substring(0, 4); if (sig.Equals("unit")) { string id = pairs[1].Substring(5, pairs[1].Length - 5); for (int i = 2; i < pairs.Length; i++) { switch (pairs[i].Substring(0, 4)) { case "move": try { string[] coords = pairs[i].Substring(5, pairs[i].Length - 5).Split(','); Unit u = ((Unit)(GameData.LevelObjects.Find(id))); u.TargetPosition = new Vector2(float.Parse(coords[0]), float.Parse(coords[1])); u.TargetUnit = null; } catch (NullReferenceException e) { string[] coords = pairs[i].Substring(5, pairs[i].Length - 5).Split(','); Unit u = ((Unit)(GameData.LevelObjects.Find(id))); if (u != null) { u.TargetPosition = new Vector2(float.Parse(coords[0]), float.Parse(coords[1])); //u.TargetUnit = null; } Console.WriteLine("null"); } break; case "targ": try { string targID = pairs[i].Substring(5, pairs[i].Length - 5); Unit theUnit = ((Unit)(GameData.LevelObjects.Find(id))); Unit targetU = (Unit)GameData.LevelObjects.Find(targID); theUnit.SetTargetUnit(targID); } catch (NullReferenceException e) { } break; case "tgbd": string bdtgID = pairs[i].Substring(5, pairs[i].Length - 5); ((Unit)(GameData.LevelObjects.Find(id))).targetBuilding = (Building)GameData.Buildings.Find(bdtgID); break; case "buil": //build break; case "damg": try { string[] parameters = pairs[i].Substring(5, pairs[i].Length - 5).Split(','); string attackerID = parameters[1]; Unit attacker = (Unit)(GameData.LevelObjects.Find(attackerID)); ((Unit)(GameData.LevelObjects.Find(id))).DealDamage(int.Parse(parameters[0]), attacker); } catch (NullReferenceException e) { Console.WriteLine(e.ToString()); } break; case "dead": try { GameData.Units.Remove(((Unit)(GameData.LevelObjects.Find(id)))); } catch (NullReferenceException e) { Console.WriteLine(e.ToString()); } break; } } } else if (sig.Equals("bdng")) { Building b = null; bool polytile = false; string id = pairs[1].Substring(5, pairs[1].Length - 5); for (int i = 2; i < pairs.Length; i++) { switch (pairs[i].Substring(0, 4)) { case "type": string type = pairs[i].Substring(5, pairs[i].Length - 5); switch (type) { case "NatureBarracks": b = new NatureBarracks(); break; case "HumanityBarrack": b = new HumanityBarrack(); polytile = true; break; case "SunlightTree": b = new SunlightTree(); break; case "NatureBase": b = new NatureBase(); polytile = true; break; case "HumanityBase": b = new HumanityBase(); polytile = true; break; case "Mine": b = new Mine(); break; case "WaterTree": b = new WaterTree(); break; } break; case "posi": string[] coords = pairs[i].Substring(5, pairs[i].Length - 5).Split(','); b.gridPosition = new Point(int.Parse(coords[0]), int.Parse(coords[1])); break; case "fnsh": GameData.LevelGrid.replaceTile((Tile)GameData.LevelGrid.Objects[b.gridPosition.X, b.gridPosition.Y], b, false); if (polytile) { ((PolyTileBuilding)b).AddQuadCoTiles(); } GameData.Buildings.Add(b); break; case "damg": try { string[] parameters = pairs[i].Substring(5, pairs[i].Length - 5).Split(','); string attackerID = parameters[1]; Unit attacker = (Unit)(GameData.LevelObjects.Find(attackerID)); ((Building)(GameData.Buildings.Find(id))).DealDamage(int.Parse(parameters[0]), attacker); } catch (NullReferenceException e) { Console.WriteLine(e.ToString()); } break; case "dead": try { GameData.Buildings.Remove(((Building)(GameData.LevelObjects.Find(id)))); } catch (NullReferenceException e) { Console.WriteLine(e.ToString()); } break; } } } else if (sig.Equals("spel")) { Spell spell = null; string id = pairs[1].Substring(5, pairs[1].Length - 5); for (int i = 2; i < pairs.Length; i++) { switch (pairs[i].Substring(0, 4)) { case "type": switch (pairs[i].Substring(5, pairs[i].Length - 5)) { case "MeteorStorm": spell = new MeteorStorm(); break; case "SnowStorm": spell = new SnowStorm(); break; case "Spell": spell = new Spell(); break; } break; case "posi": string[] coords = pairs[i].Substring(5, pairs[i].Length - 5).Split(','); spell.Position = new Vector2(float.Parse(coords[0]), float.Parse(coords[1])); break; } } spell.ID = id; GameData.LevelObjects.Add(spell); } else if (sig.Equals("addu")) { Unit u;//$addu:10$type:HumanityWorker$posi:1080,420 u = null; string id = pairs[1].Substring(5, pairs[1].Length - 5); for (int i = 2; i < pairs.Length; i++) { switch (pairs[i].Substring(0, 4)) { case "type": switch (pairs[i].Substring(5, pairs[i].Length - 5)) { case "HumanityWorker": u = new HumanityWorker(); break; case "NatureWorker": u = new NatureWorker(); break; case "Melee1": string asset = ""; asset = "natureWolf"; if (GameData.player.OppositeFaction == Player.Faction.humanity) { asset = "chainsaw"; } u = new Melee1(GameData.player.OppositeFaction, asset, id); break; case "Ranged": asset = "natureWolf"; if (GameData.player.OppositeFaction == Player.Faction.humanity) { asset = "flamethrower"; } u = new Ranged(GameData.player.OppositeFaction, asset, id); break; case "Melee2": asset = "treeUnit"; if (GameData.player.OppositeFaction == Player.Faction.humanity) { asset = "flamethrower"; } u = new Melee2(GameData.player.OppositeFaction, asset, id); break; case "FlameThrower": u = new FlameThrower(); break; case "Unicorn": asset = "unicorn"; if (GameData.player.OppositeFaction == Player.Faction.humanity) { asset = "quad"; } u = new Unicorn(GameData.player.OppositeFaction, asset, id); break; case "WoodCutter": u = new WoodCutter(); break; case "Unit": u = new Unit(); break; } break; case "posi": string[] coords = pairs[i].Substring(5, pairs[i].Length - 5).Split(','); u.Position = new Vector2(int.Parse(coords[0]), int.Parse(coords[1])); break; } } u.ID = id; GameData.Units.Add(u); GameData.unitIdIndex++; } } }
private object CanStackItem(Item item, Item targetItem) { if (_config.DisableDupeFixAndLeaveWeaponMagsAlone || (item.GetOwnerPlayer().IsUnityNull() && targetItem.GetOwnerPlayer().IsUnityNull()) ) { return(null); } // Duplicating all game checks since we're overriding them by returning true if ( item == targetItem || item.info.stackable <= 1 || targetItem.info.stackable <= 1 || item.info.itemid != targetItem.info.itemid || !item.IsValid() || item.IsBlueprint() && item.blueprintTarget != targetItem.blueprintTarget || targetItem.hasCondition && (targetItem.condition < targetItem.info.condition.max - 5) || (_config.PreventStackingDifferentSkins && item.skin != targetItem.skin) ) { return(false); } if (item.info.amountType == ItemDefinition.AmountType.Genetics || targetItem.info.amountType == ItemDefinition.AmountType.Genetics) { if ((item.instanceData?.dataInt ?? -1) != (targetItem.instanceData?.dataInt ?? -1)) { return(false); } } BaseProjectile.Magazine itemMag = targetItem.GetHeldEntity()?.GetComponent <BaseProjectile>()?.primaryMagazine; // Return ammo if (itemMag != null) { if (itemMag.contents > 0) { item.parent.AddItem(itemMag.ammoType, itemMag.contents); itemMag.contents = 0; } } if (targetItem.GetHeldEntity() is FlameThrower) { FlameThrower flameThrower = targetItem.GetHeldEntity().GetComponent <FlameThrower>(); if (flameThrower.ammo > 0) { item.parent.AddItem(flameThrower.fuelType, flameThrower.ammo); flameThrower.ammo = 0; } } if (targetItem.GetHeldEntity() is Chainsaw) { Chainsaw chainsaw = targetItem.GetHeldEntity().GetComponent <Chainsaw>(); if (chainsaw.ammo > 0) { item.parent.AddItem(chainsaw.fuelType, chainsaw.ammo); chainsaw.ammo = 0; } } return(true); }