public override void DoDamage(float damage, int itemInstanceId, Vector3D position, Vector3 normal, MyDamageType type) { // CH: TODO: Move the particle effect to definitions MyParticleEffect effect; if (MyParticlesManager.TryCreateParticleEffect((int)MyParticleEffectsIDEnum.ChipOff_Wood, out effect)) { effect.WorldMatrix = MatrixD.CreateWorld(position, Vector3.CalculatePerpendicularVector(normal), normal); effect.AutoDelete = true; } if (!Sync.IsServer) { return; } MyCutTreeInfo cutTreeInfo = default(MyCutTreeInfo); int index = -1; for (int i = 0; i < m_cutTreeInfos.Count; ++i) { cutTreeInfo = m_cutTreeInfos[i]; if (itemInstanceId == cutTreeInfo.ItemInstanceId) { index = i; break; } } if (index == -1) { cutTreeInfo = new MyCutTreeInfo(); cutTreeInfo.ItemInstanceId = itemInstanceId; index = m_cutTreeInfos.Count; m_cutTreeInfos.Add(cutTreeInfo); } cutTreeInfo.LastHit = MySandboxGame.TotalGamePlayTimeInMilliseconds; cutTreeInfo.Progress += damage; if (cutTreeInfo.Progress >= 1) { if (type != MyDamageType.Drill) { position.Y = m_itemsData[itemInstanceId].Transform.Position.Y; } CutTree(itemInstanceId, position, normal); m_cutTreeInfos.RemoveAtFast(index); } else { m_cutTreeInfos[index] = cutTreeInfo; } return; }
private void UpdateTreeInfos() { int totalGamePlayTimeInMilliseconds = MySandboxGame.TotalGamePlayTimeInMilliseconds; int num2 = 0xea60; for (int i = this.m_cutTreeInfos.Count - 1; i >= 0; i--) { MyCutTreeInfo info = this.m_cutTreeInfos[i]; if ((totalGamePlayTimeInMilliseconds - info.LastHit) > num2) { this.m_cutTreeInfos.RemoveAtFast <MyCutTreeInfo>(i); } } }
public override unsafe void DoDamage(float damage, int itemInstanceId, Vector3D position, Vector3 normal, MyStringHash type) { MyParticleEffect effect; MyEnvironmentItems.MyEnvironmentItemData data = base.m_itemsData[itemInstanceId]; MyDefinitionId id = new MyDefinitionId(base.Definition.ItemDefinitionType, data.SubtypeId); MyTreeDefinition environmentItemDefinition = (MyTreeDefinition)MyDefinitionManager.Static.GetEnvironmentItemDefinition(id); MyParticlesManager.TryCreateParticleEffect(environmentItemDefinition.CutEffect, MatrixD.CreateWorld(position, Vector3.CalculatePerpendicularVector(normal), normal), out effect); if (Sync.IsServer) { MyCutTreeInfo item = new MyCutTreeInfo(); int index = -1; int num2 = 0; while (true) { if (num2 < this.m_cutTreeInfos.Count) { item = this.m_cutTreeInfos[num2]; if (itemInstanceId != item.ItemInstanceId) { num2++; continue; } index = num2; } if (index == -1) { item = new MyCutTreeInfo { ItemInstanceId = itemInstanceId }; MyCutTreeInfo *infoPtr1 = (MyCutTreeInfo *)ref item; infoPtr1->MaxPoints = item.HitPoints = environmentItemDefinition.HitPoints; index = this.m_cutTreeInfos.Count; this.m_cutTreeInfos.Add(item); } item.LastHit = MySandboxGame.TotalGamePlayTimeInMilliseconds; float *singlePtr1 = (float *)ref item.HitPoints; singlePtr1[0] -= damage; if (item.Progress < 1f) { this.m_cutTreeInfos[index] = item; return; } this.CutTree(itemInstanceId, position, normal, (type == MyDamageType.Drill) ? 1f : 4f); this.m_cutTreeInfos.RemoveAtFast <MyCutTreeInfo>(index); return; } } }
public override void DoDamage(float damage, int itemInstanceId, Vector3D position, Vector3 normal, MyStringHash type) { MyEnvironmentItemData itemData = m_itemsData[itemInstanceId]; MyDefinitionId id = new MyDefinitionId(Definition.ItemDefinitionType, itemData.SubtypeId); var itemDefinition = (MyTreeDefinition)MyDefinitionManager.Static.GetEnvironmentItemDefinition(id); int effectId; if (itemDefinition.CutEffect != null && MyParticlesLibrary.GetParticleEffectsID(itemDefinition.CutEffect, out effectId)) { MyParticleEffect effect; if (MyParticlesManager.TryCreateParticleEffect(effectId, out effect)) { effect.WorldMatrix = MatrixD.CreateWorld(position, Vector3.CalculatePerpendicularVector(normal), normal); effect.AutoDelete = true; } } if (!Sync.IsServer) { return; } MyCutTreeInfo cutTreeInfo = default(MyCutTreeInfo); int index = -1; for (int i = 0; i < m_cutTreeInfos.Count; ++i) { cutTreeInfo = m_cutTreeInfos[i]; if (itemInstanceId == cutTreeInfo.ItemInstanceId) { index = i; break; } } if (index == -1) { cutTreeInfo = new MyCutTreeInfo(); cutTreeInfo.ItemInstanceId = itemInstanceId; cutTreeInfo.MaxPoints = cutTreeInfo.HitPoints = itemDefinition.HitPoints; index = m_cutTreeInfos.Count; m_cutTreeInfos.Add(cutTreeInfo); } cutTreeInfo.LastHit = MySandboxGame.TotalGamePlayTimeInMilliseconds; cutTreeInfo.HitPoints -= damage; if (cutTreeInfo.Progress >= 1) { CutTree(itemInstanceId, position, normal, type == MyDamageType.Drill ? 1.0f : 4.0f); m_cutTreeInfos.RemoveAtFast(index); } else { m_cutTreeInfos[index] = cutTreeInfo; } return; }