public static void Send(Effect effect, Connection target) { effect.pooledstringid = StringPool.Get(effect.pooledString); if (effect.pooledstringid == 0) { Debug.LogWarning(string.Concat("EffectNetwork.Send - unpooled effect name: ", effect.pooledString)); return; } Net.sv.write.Start(); Net.sv.write.PacketID(Message.Type.Effect); effect.WriteToStream(Net.sv.write); Net.sv.write.Send(new SendInfo(target)); }
private void Awake() { Entity = GetComponent <BaseHelicopter>(); AI = Entity.myAI; tr = Entity.transform; AI.enabled = false; _targets = Facepunch.Pool.GetList <PatrolHelicopterAI.targetinfo>(); tailRotorBone = StringPool.Get("tail_rotor_col"); mainRotorBone = StringPool.Get("main_rotor_col"); }
public override void DoAction(Item item, BasePlayer player) { if (item.hasCondition && item.conditionNormalized != 0f && !(player == null) && !(player.WaterFactor() < 1f) && item.parent != null && item.parent == player.inventory.containerWear) { Effect.server.Run((!inhaled) ? inhaleEffect.resourcePath : exhaleEffect.resourcePath, player, StringPool.Get("jaw"), Vector3.zero, Vector3.forward); inhaled = !inhaled; if (!inhaled && WaterLevel.GetWaterDepth(player.eyes.position, player) > 3f) { Effect.server.Run(bubblesEffect.resourcePath, player, StringPool.Get("jaw"), Vector3.zero, Vector3.forward); } item.LoseCondition(amountToConsume); player.metabolism.oxygen.Add(1f); } }
public static void Send(Effect effect) { if (Net.sv == null || !Net.sv.IsConnected()) { return; } using (TimeWarning.New("EffectNetwork.Send")) { Group group = null; if (!string.IsNullOrEmpty(effect.pooledString)) { effect.pooledstringid = StringPool.Get(effect.pooledString); } if (effect.pooledstringid == 0) { Debug.Log("String ID is 0 - unknown effect " + effect.pooledString); return; } if (effect.broadcast) { if (Net.sv.write.Start()) { Net.sv.write.PacketID(Message.Type.Effect); effect.WriteToStream(Net.sv.write); Net.sv.write.Send(new SendInfo(BaseNetworkable.GlobalNetworkGroup.subscribers)); } return; } if (effect.entity != 0) { BaseEntity baseEntity = BaseNetworkable.serverEntities.Find(effect.entity) as BaseEntity; if (!BaseEntityEx.IsValid(baseEntity)) { return; } group = baseEntity.net.group; goto IL_0113; } group = Net.sv.visibility.GetGroup(effect.worldPos); goto IL_0113; IL_0113: if (group != null) { Net.sv.write.Start(); Net.sv.write.PacketID(Message.Type.Effect); effect.WriteToStream(Net.sv.write); Net.sv.write.Send(new SendInfo(group.subscribers)); } } }
public void Hurt(float amount, HitInfo info) { if (this.isDestroyed) { return; } this.health -= amount; Effect.server.Run(this.damagedParticles.resourcePath, this.body, StringPool.Get(this.bonenames[UnityEngine.Random.Range(0, (int)this.bonenames.Length)]), Vector3.zero, Vector3.up, null, true); if (this.health <= 0f) { this.health = 0f; this.WeakspotDestroyed(); } }
public void PostProcess( IPrefabProcessor preProcess, GameObject rootObj, string name, bool serverside, bool clientside, bool bundling) { if (bundling) { return; } this.Initialize(StringPool.Get(name)); }
public void FireGun(Vector3 targetPos, float aimCone, bool left) { RaycastHit raycastHit; if (PatrolHelicopter.guns == 0) { return; } Vector3 vector3 = ((left ? this.helicopterBase.left_gun_muzzle.transform : this.helicopterBase.right_gun_muzzle.transform)).position; Vector3 vector31 = (targetPos - vector3).normalized; vector3 = vector3 + (vector31 * 2f); Vector3 modifiedAimConeDirection = AimConeUtil.GetModifiedAimConeDirection(aimCone, vector31, true); if (!GamePhysics.Trace(new Ray(vector3, modifiedAimConeDirection), 0f, out raycastHit, 300f, 1219701521, QueryTriggerInteraction.UseGlobal)) { targetPos = vector3 + (modifiedAimConeDirection * 300f); } else { targetPos = raycastHit.point; if (raycastHit.collider) { BaseEntity entity = raycastHit.GetEntity(); if (entity && entity != this.helicopterBase) { BaseCombatEntity baseCombatEntity = entity as BaseCombatEntity; HitInfo hitInfo = new HitInfo(this.helicopterBase, entity, DamageType.Bullet, this.helicopterBase.bulletDamage * PatrolHelicopter.bulletDamageScale, raycastHit.point); if (!baseCombatEntity) { entity.OnAttacked(hitInfo); } else { baseCombatEntity.OnAttacked(hitInfo); if (baseCombatEntity is BasePlayer) { Effect.server.ImpactEffect(new HitInfo() { HitPositionWorld = raycastHit.point - (modifiedAimConeDirection * 0.25f), HitNormalWorld = -modifiedAimConeDirection, HitMaterial = StringPool.Get("Flesh") }); } } } } } this.helicopterBase.ClientRPC <bool, Vector3>(null, "FireGun", left, targetPos); }
public void WeaponTick() { if (this.IsDead()) { return; } if (Time.time < this.lockOnTime) { return; } if (Time.time < this.nextBurstTime) { return; } if (!this.IsPowered()) { this.firedCount = 0; return; } if (this.firedCount >= 6) { this.nextBurstTime = Time.time + 5f; this.firedCount = 0; return; } this.EnsureReloaded(); if (!this.HasAmmo()) { return; } if (Interface.CallHook("CanSamSiteShoot", this) != null) { return; } if (!this.staticRespawn && this.ammoItem != null) { this.ammoItem.UseItem(1); } this.firedCount++; this.FireProjectile(this.tubes[this.currentTubeIndex].position, this.currentAimDir, this.currentTarget); int num = this.currentTubeIndex + 1; Effect.server.Run(this.muzzleFlashTest.resourcePath, this, StringPool.Get(string.Concat("Tube ", num.ToString())), Vector3.zero, Vector3.up, null, false); this.currentTubeIndex++; if (this.currentTubeIndex >= (int)this.tubes.Length) { this.currentTubeIndex = 0; } }
public override void DoAction(Item item, BasePlayer player) { if (!item.hasCondition || (double)item.conditionNormalized == 0.0 || (Object.op_Equality((Object)player, (Object)null) || (double)player.WaterFactor() < 1.0) || (item.parent == null || item.parent != player.inventory.containerWear)) { return; } Effect.server.Run(!this.inhaled ? this.inhaleEffect.resourcePath : this.exhaleEffect.resourcePath, (BaseEntity)player, StringPool.Get("jaw"), Vector3.get_zero(), Vector3.get_forward(), (Connection)null, false); this.inhaled = !this.inhaled; if (!this.inhaled && (double)WaterLevel.GetWaterDepth(player.eyes.position) > 3.0) { Effect.server.Run(this.bubblesEffect.resourcePath, (BaseEntity)player, StringPool.Get("jaw"), Vector3.get_zero(), Vector3.get_forward(), (Connection)null, false); } item.LoseCondition((float)this.amountToConsume); player.metabolism.oxygen.Add(1f); }
public static void Send(Effect effect, Connection target) { effect.pooledstringid = (__Null)(int)StringPool.Get(effect.pooledString); if (effect.pooledstringid == null) { Debug.LogWarning((object)("EffectNetwork.Send - unpooled effect name: " + effect.pooledString)); } else { ((Write)((NetworkPeer)Net.sv).write).Start(); ((Write)((NetworkPeer)Net.sv).write).PacketID((Message.Type) 13); effect.WriteToStream((Stream)((NetworkPeer)Net.sv).write); ((Write)((NetworkPeer)Net.sv).write).Send(new SendInfo(target)); } }
private void OnWeaponFired(BaseProjectile aProjectile, BasePlayer aPlayer, ItemModProjectile aMod, ProtoBuf.ProjectileShoot aProjectileProtoBuf) { TaserController theController = aProjectile.GetComponent <TaserController>(); if (theController) { theController.ResetTaser(); if (!permission.UserHasPermission(aPlayer.UserIDString, PERMISSION_USETASER)) { Effect.server.Run(config.PrefabShock, aProjectile, StringPool.Get(aProjectile.MuzzleTransform.name), aProjectile.MuzzleTransform.localPosition, Vector3.zero); aPlayer.OnAttacked(new HitInfo(aPlayer, aPlayer, DamageType.ElectricShock, config.NoUsePermissionDamage, aPlayer.transform.position + aPlayer.transform.forward * 1f)); Message(aPlayer, I18N_NOT_ALLOWED_TO_USE); } } }
private void ApplyDamage(BaseCombatEntity entity, Vector3 point, Vector3 normal) { float single = this.bulletDamage * UnityEngine.Random.Range(0.9f, 1.1f); entity.OnAttacked(new HitInfo(this, entity, DamageType.Bullet, single, point)); if (entity is BasePlayer || entity is BaseNpc) { Effect.server.ImpactEffect(new HitInfo() { HitPositionWorld = point, HitNormalWorld = -normal, HitMaterial = StringPool.Get("Flesh") }); } }
private static void Spawn( string category, uint id, Vector3 position, Quaternion rotation, Vector3 scale) { GameObject prefab = Prefab.DefaultManager.CreatePrefab(StringPool.Get(id), position, rotation, scale, true); if (!Object.op_Implicit((Object)prefab)) { return; } prefab.SetHierarchyGroup(category, true, false); }
public static Prefab <T> Load <T>(uint id, GameManager manager = null, PrefabAttribute.Library attribute = null) where T : Component { if (manager == null) { manager = Prefab.DefaultManager; } if (attribute == null) { attribute = Prefab.DefaultAttribute; } string str = StringPool.Get(id); GameObject gameObject = manager.FindPrefab(str); return(new Prefab <T>(str, gameObject, gameObject.GetComponent <T>(), manager, attribute)); }
public void SpawnVisual(BasePlayer player) { if (_visualEntity != null || !Configuration.ShowOnBack) { return; } var entity = GameManager.server.CreateEntity(BackpackPrefab, new Vector3(0, -0.1f, 0), Quaternion.Euler(-5, -90, 180)); entity.SetParent(player, StringPool.Get(BackBone)); entity.SetFlag(BaseEntity.Flags.Locked, true); entity.Spawn(); entity.name = "backpack"; _visualEntity = entity; }
void OnEntitySpawned(BaseNetworkable entity) { heliPrefabId = StringPool.Get(heliPrefab); if (entity == null) { return; } if (entity.prefabID == heliPrefabId) { entity.KillMessage(); Puts("NoHeli : Patrol Stopped!"); //PrintToConsole("Heli Stopped"); If you want to broadcast on console return; } }
private void SendEffectTo(string effect, BasePlayer player) { if (player == null) { return; } Effect EffectInstance = new Effect(); EffectInstance.Init(Effect.Type.Generic, player, 0, Vector3.up, Vector3.zero); EffectInstance.pooledstringid = StringPool.Get(effect); Net.sv.write.Start(); Net.sv.write.PacketID(Network.Message.Type.Effect); EffectInstance.WriteToStream(Net.sv.write); Net.sv.write.Send(new SendInfo(player.net.connection)); EffectInstance.Clear(); }
public virtual void FireGun( Vector3 targetPos, float aimCone, Transform muzzleToUse = null, BaseCombatEntity target = null) { if (this.IsOffline()) { return; } if (Object.op_Equality((Object)muzzleToUse, (Object)null)) { muzzleToUse = this.muzzlePos; } Vector3 vector3_1 = Vector3.op_Subtraction(((Component)this.GetCenterMuzzle()).get_transform().get_position(), Vector3.op_Multiply(this.GetCenterMuzzle().get_forward(), 0.25f)); Vector3 forward = ((Component)this.GetCenterMuzzle()).get_transform().get_forward(); Vector3 aimConeDirection = AimConeUtil.GetModifiedAimConeDirection(aimCone, forward, true); targetPos = Vector3.op_Addition(vector3_1, Vector3.op_Multiply(aimConeDirection, 300f)); List <RaycastHit> list = (List <RaycastHit>)Pool.GetList <RaycastHit>(); GamePhysics.TraceAll(new Ray(vector3_1, aimConeDirection), 0.0f, list, 300f, 1219701521, (QueryTriggerInteraction)0); for (int index = 0; index < list.Count; ++index) { RaycastHit hit = list[index]; BaseEntity entity1 = hit.GetEntity(); if ((!Object.op_Inequality((Object)entity1, (Object)null) || !Object.op_Equality((Object)entity1, (Object)this) && !entity1.EqualNetID((BaseNetworkable)this)) && (!Object.op_Inequality((Object)target, (Object)null) || !Object.op_Inequality((Object)entity1, (Object)null) || (!Object.op_Inequality((Object)((Component)entity1).GetComponent <BasePlayer>(), (Object)null) || entity1.EqualNetID((BaseNetworkable)target)))) { BaseCombatEntity entity2 = entity1 as BaseCombatEntity; if (Object.op_Inequality((Object)entity2, (Object)null)) { this.ApplyDamage(entity2, ((RaycastHit) ref hit).get_point(), aimConeDirection); } if (!Object.op_Inequality((Object)entity1, (Object)null) || entity1.ShouldBlockProjectiles()) { targetPos = ((RaycastHit) ref hit).get_point(); Vector3 vector3_2 = Vector3.op_Subtraction(targetPos, vector3_1); ((Vector3) ref vector3_2).get_normalized(); break; } } } this.ClientRPC <uint, Vector3>((Connection)null, "CLIENT_FireGun", StringPool.Get(((Object)((Component)muzzleToUse).get_gameObject()).get_name()), targetPos); // ISSUE: cast to a reference type Pool.FreeList <RaycastHit>((List <M0>&) ref list); }
public override void OnAttacked(HitInfo info) { if (this.isServer) { if (StringPool.Get(info.HitBone) == "laptopcollision") { Effect.server.Run(this.shockEffect.resourcePath, info.HitPositionWorld, Vector3.get_up(), (Connection)null, false); this.hackSeconds -= (float)(8.0 * ((double)info.damageTypes.Total() / 50.0)); if ((double)this.hackSeconds < 0.0) { this.hackSeconds = 0.0f; } } this.RefreshDecay(); } base.OnAttacked(info); }
public override void OnAttacked(HitInfo info) { if (base.isServer) { if (StringPool.Get(info.HitBone) == "laptopcollision") { Effect.server.Run(shockEffect.resourcePath, info.HitPositionWorld, Vector3.up); hackSeconds -= 8f * (info.damageTypes.Total() / 50f); if (hackSeconds < 0f) { hackSeconds = 0f; } } RefreshDecay(); } base.OnAttacked(info); }
private void BuildDictionary() { this.quickLookup = new Dictionary <uint, SkeletonProperties.BoneProperty>(); foreach (SkeletonProperties.BoneProperty bone in this.bones) { uint key = StringPool.Get(((Object)bone.bone).get_name()); if (!this.quickLookup.ContainsKey(key)) { this.quickLookup.Add(key, bone); } else { string name1 = ((Object)bone.bone).get_name(); string name2 = ((Object)this.quickLookup[key].bone).get_name(); Debug.LogWarning((object)("Duplicate bone id " + (object)key + " for " + name1 + " and " + name2)); } } }
private static void Init() { if (StringPool.initialized) { return; } StringPool.toString = new Dictionary <uint, string>(); StringPool.toNumber = new Dictionary <string, uint>((IEqualityComparer <string>)StringComparer.OrdinalIgnoreCase); GameManifest gameManifest = FileSystem.Load <GameManifest>("Assets/manifest.asset", true); for (uint index = 0; (long)index < (long)gameManifest.pooledStrings.Length; ++index) { StringPool.toString.Add(gameManifest.pooledStrings[index].hash, gameManifest.pooledStrings[index].str); StringPool.toNumber.Add(gameManifest.pooledStrings[index].str, gameManifest.pooledStrings[index].hash); } StringPool.initialized = true; StringPool.closest = StringPool.Get("closest"); }
public override void ServerCommand(Item item, string command, BasePlayer player) { if (item.GetOwnerPlayer() != player) { bool flag = false; foreach (ItemContainer container in player.inventory.loot.containers) { if (item.GetRootContainer() != container) { continue; } flag = true; goto Label0; } Label0: if (!flag) { return; } } if (command == "study") { if (!item.IsBlueprint()) { return; } ItemDefinition itemDefinition = item.blueprintTargetDef; if (player.blueprints.IsUnlocked(itemDefinition)) { return; } Item item1 = item; if (item.amount > 1) { item1 = item.SplitItem(1); } item1.UseItem(1); player.blueprints.Unlock(itemDefinition); if (this.studyEffect.isValid) { Effect.server.Run(this.studyEffect.resourcePath, player, StringPool.Get("head"), Vector3.zero, Vector3.zero, null, false); } } }
public static Projectile CreateProjectile(BaseProjectile baseProjectile, string prefabPath, Vector3 pos, Vector3 forward, Vector3 velocity) { GameObject gameObject = GameManager.client.CreatePrefab(prefabPath, pos, Quaternion.LookRotation(forward), false); if (gameObject == null) { return(null); } if (ConVar.Pool.projectiles) { gameObject.EnablePooling(StringPool.Get(prefabPath)); } gameObject.AwakeFromInstantiate(); Projectile component = gameObject.GetComponent <Projectile>(); component.InitializeVelocity(velocity); component.modifier = baseProjectile.GetProjectileModifier(); return(component); }
void OnPlayerInit(BasePlayer player) { PetInfo info; if (SaveNpcList.TryGetValue(player.userID.ToString(), out info) && info.NeedToSpawn) { Puts("Loading pet..."); BaseEntity pet = GameManager.server.CreateEntity(StringPool.Get(info.prefabID), new Vector3(info.x, info.y, info.z)); if (pet != null) { NpcControl comp = player.gameObject.AddComponent <NpcControl>(); pet.Spawn(true); comp.npc = pet.gameObject.AddComponent <NpcAI>(); comp.npc.owner = comp; comp.npc.inventory.Load(ProtoBuf.ItemContainer.Deserialize(info.inventory)); info.NeedToSpawn = false; } } }
public override void ServerCommand(Item item, string command, BasePlayer player) { if (Object.op_Inequality((Object)item.GetOwnerPlayer(), (Object)player)) { bool flag = false; foreach (ItemContainer container in player.inventory.loot.containers) { if (item.GetRootContainer() == container) { flag = true; break; } } if (!flag) { return; } } if (!(command == "study") || !item.IsBlueprint()) { return; } ItemDefinition blueprintTargetDef = item.blueprintTargetDef; if (player.blueprints.IsUnlocked(blueprintTargetDef)) { return; } Item obj = item; if (item.amount > 1) { obj = item.SplitItem(1); } obj.UseItem(1); player.blueprints.Unlock(blueprintTargetDef); if (!this.studyEffect.isValid) { return; } Effect.server.Run(this.studyEffect.resourcePath, (BaseEntity)player, StringPool.Get("head"), Vector3.get_zero(), Vector3.get_zero(), (Connection)null, false); }
private void BuildDictionary() { this.quickLookup = new Dictionary <uint, SkeletonProperties.BoneProperty>(); SkeletonProperties.BoneProperty[] bonePropertyArray = this.bones; for (int i = 0; i < (int)bonePropertyArray.Length; i++) { SkeletonProperties.BoneProperty boneProperty = bonePropertyArray[i]; uint num = StringPool.Get(boneProperty.bone.name); if (this.quickLookup.ContainsKey(num)) { string str = boneProperty.bone.name; string item = this.quickLookup[num].bone.name; Debug.LogWarning(string.Concat(new object[] { "Duplicate bone id ", num, " for ", str, " and ", item })); } else { this.quickLookup.Add(num, boneProperty); } } }
public void FireBullet() { float damageAmount = 10f; Vector3 vector = muzzlePos.transform.position - muzzlePos.forward * 0.25f; Vector3 vector2 = AimConeUtil.GetModifiedAimConeDirection(inputVec: muzzlePos.transform.forward, aimCone: aimCone); Vector3 arg = vector + vector2 * 300f; ClientRPC(null, "CLIENT_FireGun", arg); List <RaycastHit> list = Pool.GetList <RaycastHit>(); int layerMask = 1219701505; GamePhysics.TraceAll(new Ray(vector, vector2), 0.1f, list, 300f, layerMask); for (int i = 0; i < list.Count; i++) { RaycastHit hit = list[i]; BaseEntity entity = RaycastHitEx.GetEntity(hit); if (entity != null && (entity == this || entity.EqualNetID(this))) { continue; } if (entity as BaseCombatEntity != null) { HitInfo info = new HitInfo(this, entity, DamageType.Bullet, damageAmount, hit.point); entity.OnAttacked(info); if (entity is BasePlayer || entity is BaseNpc) { Effect.server.ImpactEffect(new HitInfo { HitPositionWorld = hit.point, HitNormalWorld = -hit.normal, HitMaterial = StringPool.Get("Flesh") }); } } if (!(entity != null) || entity.ShouldBlockProjectiles()) { arg = hit.point; break; } } }
private void OnServerInitialized() { if (isUpgradeBlockedMethod == null) { PrintError("IsUpgradeBlocked == null. Please notify the plugin developer"); } foreach (var entry in configData.categories) { var values = new HashSet <uint>(); foreach (var prefab in entry.Value) { var item = StringPool.Get(prefab); if (item == 0u) { continue; } values.Add(item); } categories.Add(entry.Key, values); } }
bool GetDeployableClean(BuildingBlock initialBlock, float playerRot, Deployable currentBlock, out Dictionary <string, object> data) { data = new Dictionary <string, object>(); posCleanData = new Dictionary <string, object>(); rotCleanData = new Dictionary <string, object>(); normedPos = GenerateGoodPos(initialBlock.transform.position, currentBlock.transform.position, playerRot); normedYRot = currentBlock.transform.rotation.ToEulerAngles().y - playerRot; data.Add("prefabname", StringPool.Get(currentBlock.prefabID).ToString()); posCleanData.Add("x", normedPos.x); posCleanData.Add("y", normedPos.y); posCleanData.Add("z", normedPos.z); data.Add("pos", posCleanData); rotCleanData.Add("x", currentBlock.transform.rotation.ToEulerAngles().x); rotCleanData.Add("y", normedYRot); rotCleanData.Add("z", currentBlock.transform.rotation.ToEulerAngles().z); data.Add("rot", rotCleanData); return(true); }
/// <summary> /// Write helper /// </summary> internal static void Write(ResWriter writer, StringPool pool, string value, int resourceId = -1) { var index = (value == null) ? -1 : pool.Get(value, resourceId); writer.WriteInt32(index); }