Exemplo n.º 1
0
        partial void UpdateProjSpecific(float deltaTime)
        {
            if (FakeBrokenTimer > 0.0f)
            {
                item.FakeBroken = true;
                if (Character.Controlled == null || (Character.Controlled.CharacterHealth.GetAffliction("psychosis")?.Strength ?? 0.0f) <= 0.0f)
                {
                    FakeBrokenTimer = 0.0f;
                }
                else
                {
                    FakeBrokenTimer -= deltaTime;
                }
            }
            else
            {
                item.FakeBroken = false;
            }


            if (!GameMain.IsMultiplayer)
            {
                switch (requestStartFixAction)
                {
                case FixActions.Repair:
                case FixActions.Sabotage:
                case FixActions.Tinker:
                    StartRepairing(Character.Controlled, requestStartFixAction);
                    requestStartFixAction = FixActions.None;
                    break;

                default:
                    requestStartFixAction = FixActions.None;
                    break;
                }
            }

            for (int i = 0; i < particleEmitters.Count; i++)
            {
                if ((item.ConditionPercentage >= particleEmitterConditionRanges[i].X && item.ConditionPercentage <= particleEmitterConditionRanges[i].Y) || FakeBrokenTimer > 0.0f)
                {
                    particleEmitters[i].Emit(deltaTime, item.WorldPosition, item.CurrentHull);
                }
            }

            if (CurrentFixer != null && CurrentFixer.SelectedConstruction == item)
            {
                if (repairSoundChannel == null || !repairSoundChannel.IsPlaying)
                {
                    repairSoundChannel = SoundPlayer.PlaySound("repair", item.WorldPosition, hullGuess: item.CurrentHull);
                }
            }
            else
            {
                repairSoundChannel?.FadeOutAndDispose();
                repairSoundChannel = null;
            }
        }
Exemplo n.º 2
0
        partial void UpdateProjSpecific(float deltaTime)
        {
            if (!GameMain.IsMultiplayer)
            {
                switch (requestStartFixAction)
                {
                case FixActions.Repair:
                case FixActions.Sabotage:
                    StartRepairing(Character.Controlled, requestStartFixAction);
                    requestStartFixAction = FixActions.None;
                    break;

                default:
                    requestStartFixAction = FixActions.None;
                    break;
                }
            }

            for (int i = 0; i < particleEmitters.Count; i++)
            {
                if (item.ConditionPercentage >= particleEmitterConditionRanges[i].X && item.ConditionPercentage <= particleEmitterConditionRanges[i].Y)
                {
                    particleEmitters[i].Emit(deltaTime, item.WorldPosition, item.CurrentHull);
                }
            }

            if (CurrentFixer != null && CurrentFixer.SelectedConstruction == item)
            {
                if (repairSoundChannel == null || !repairSoundChannel.IsPlaying)
                {
                    repairSoundChannel = SoundPlayer.PlaySound("repair", item.WorldPosition, hullGuess: item.CurrentHull);
                }
            }
            else
            {
                repairSoundChannel?.FadeOutAndDispose();
                repairSoundChannel = null;
            }
        }
Exemplo n.º 3
0
        partial void InitProjSpecific(XElement element)
        {
            var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.8f, 0.75f), GuiFrame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter)
            {
                Stretch         = true,
                RelativeSpacing = 0.05f,
                CanBeFocused    = true
            };

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.15f), paddedFrame.RectTransform),
                             header, textAlignment: Alignment.TopCenter, font: GUI.LargeFont);

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedFrame.RectTransform),
                             Description, font: GUI.SmallFont, wrap: true);

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedFrame.RectTransform),
                             TextManager.Get("RequiredRepairSkills"), font: GUI.SubHeadingFont);
            for (int i = 0; i < requiredSkills.Count; i++)
            {
                var skillText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedFrame.RectTransform),
                                                 "   - " + TextManager.AddPunctuation(':', TextManager.Get("SkillName." + requiredSkills[i].Identifier), ((int)requiredSkills[i].Level).ToString()),
                                                 font: GUI.SmallFont)
                {
                    UserData = requiredSkills[i]
                };
            }

            var progressBarHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform), isHorizontal: true)
            {
                Stretch         = true,
                RelativeSpacing = 0.02f
            };

            progressBar = new GUIProgressBar(new RectTransform(new Vector2(0.6f, 1.0f), progressBarHolder.RectTransform),
                                             color: GUI.Style.Green, barSize: 0.0f, style: "DeviceProgressBar");
            repairButtonText = TextManager.Get("RepairButton");
            repairingText    = TextManager.Get("Repairing");
            RepairButton     = new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), progressBarHolder.RectTransform, Anchor.TopCenter), repairButtonText)
            {
                OnClicked = (btn, obj) =>
                {
                    requestStartFixAction = FixActions.Repair;
                    item.CreateClientEvent(this);
                    return(true);
                }
            };
            RepairButton.TextBlock.AutoScaleHorizontal = true;
            progressBarHolder.RectTransform.MinSize    = RepairButton.RectTransform.MinSize;
            RepairButton.RectTransform.MinSize         = new Point((int)(RepairButton.TextBlock.TextSize.X * 1.2f), RepairButton.RectTransform.MinSize.Y);

            sabotageButtonText = TextManager.Get("SabotageButton");
            sabotagingText     = TextManager.Get("Sabotaging");
            SabotageButton     = new GUIButton(new RectTransform(new Vector2(0.8f, 0.15f), paddedFrame.RectTransform, Anchor.BottomCenter), sabotageButtonText, style: "GUIButtonSmall")
            {
                IgnoreLayoutGroups = true,
                Visible            = false,
                OnClicked          = (btn, obj) =>
                {
                    requestStartFixAction = FixActions.Sabotage;
                    item.CreateClientEvent(this);
                    return(true);
                }
            };

            foreach (XElement subElement in element.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
                case "emitter":
                case "particleemitter":
                    particleEmitters.Add(new ParticleEmitter(subElement));
                    float minCondition = subElement.GetAttributeFloat("mincondition", 0.0f);
                    float maxCondition = subElement.GetAttributeFloat("maxcondition", 100.0f);

                    if (maxCondition < minCondition)
                    {
                        DebugConsole.ThrowError("Invalid damage particle configuration in the Repairable component of " + item.Name + ". MaxCondition needs to be larger than MinCondition.");
                        float temp = maxCondition;
                        maxCondition = minCondition;
                        minCondition = temp;
                    }
                    particleEmitterConditionRanges.Add(new Vector2(minCondition, maxCondition));

                    break;
                }
            }
        }
Exemplo n.º 4
0
        private void CreateGUI()
        {
            var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.8f, 0.75f), GuiFrame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter)
            {
                Stretch = true,
                RelativeSpacing = 0.05f,
                CanBeFocused = true
            };
            
            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.15f), paddedFrame.RectTransform),
                header, textAlignment: Alignment.TopCenter, font: GUI.LargeFont);

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedFrame.RectTransform),
                Description, font: GUI.SmallFont, wrap: true);

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedFrame.RectTransform),
                TextManager.Get("RequiredRepairSkills"), font: GUI.SubHeadingFont);
            for (int i = 0; i < requiredSkills.Count; i++)
            {
                var skillText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedFrame.RectTransform),
                    "   - " + TextManager.AddPunctuation(':', TextManager.Get("SkillName." + requiredSkills[i].Identifier), ((int) Math.Round(requiredSkills[i].Level * SkillRequirementMultiplier)).ToString()),
                    font: GUI.SmallFont)
                {
                    UserData = requiredSkills[i]
                };
            }

            var progressBarHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform), isHorizontal: true)
            {
                Stretch = true,
                RelativeSpacing = 0.02f
            };

            progressBar = new GUIProgressBar(new RectTransform(new Vector2(0.6f, 1.0f), progressBarHolder.RectTransform),
                color: GUI.Style.Green, barSize: 0.0f, style: "DeviceProgressBar");
            repairButtonText = TextManager.Get("RepairButton");
            repairingText = TextManager.Get("Repairing");
            RepairButton = new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), progressBarHolder.RectTransform, Anchor.TopCenter), repairButtonText)
            {
                OnClicked = (btn, obj) =>
                {
                    requestStartFixAction = FixActions.Repair;
                    item.CreateClientEvent(this);
                    return true;
                }
            };
            RepairButton.TextBlock.AutoScaleHorizontal = true;
            progressBarHolder.RectTransform.MinSize = RepairButton.RectTransform.MinSize;
            RepairButton.RectTransform.MinSize = new Point((int)(RepairButton.TextBlock.TextSize.X * 1.2f), RepairButton.RectTransform.MinSize.Y);

            sabotageButtonText = TextManager.Get("SabotageButton");
            sabotagingText = TextManager.Get("Sabotaging");
            SabotageButton = new GUIButton(new RectTransform(new Vector2(0.8f, 0.15f), paddedFrame.RectTransform, Anchor.BottomCenter), sabotageButtonText, style: "GUIButtonSmall")
            {
                IgnoreLayoutGroups = true,
                Visible = false,
                OnClicked = (btn, obj) =>
                {
                    requestStartFixAction = FixActions.Sabotage;
                    item.CreateClientEvent(this);
                    return true;
                }
            };
        }
Exemplo n.º 5
0
        partial void InitProjSpecific(XElement element)
        {
            var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.85f), GuiFrame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter)
            {
                Stretch         = true,
                RelativeSpacing = 0.05f
            };

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.15f), paddedFrame.RectTransform),
                             header, textAlignment: Alignment.TopCenter, font: GUI.LargeFont);

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedFrame.RectTransform),
                             Description, font: GUI.SmallFont, wrap: true);

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.15f), paddedFrame.RectTransform),
                             TextManager.Get("RequiredRepairSkills"));
            for (int i = 0; i < requiredSkills.Count; i++)
            {
                var skillText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.15f), paddedFrame.RectTransform),
                                                 "   - " + TextManager.AddPunctuation(':', TextManager.Get("SkillName." + requiredSkills[i].Identifier), ((int)requiredSkills[i].Level).ToString()),
                                                 font: GUI.SmallFont)
                {
                    UserData = requiredSkills[i]
                };
            }

            progressBar = new GUIProgressBar(new RectTransform(new Vector2(1.0f, 0.15f), paddedFrame.RectTransform),
                                             color: Color.Green, barSize: 0.0f);

            repairButtonText = TextManager.Get("RepairButton");
            repairingText    = TextManager.Get("Repairing");
            repairButton     = new GUIButton(new RectTransform(new Vector2(0.8f, 0.15f), paddedFrame.RectTransform, Anchor.TopCenter), repairButtonText)
            {
                OnClicked = (btn, obj) =>
                {
                    requestStartFixAction = FixActions.Repair;
                    item.CreateClientEvent(this);
                    return(true);
                }
            };
            sabotageButtonText = TextManager.Get("SabotageButton");
            sabotagingText     = TextManager.Get("Sabotaging");
            sabotageButton     = new GUIButton(new RectTransform(new Vector2(0.8f, 0.15f), paddedFrame.RectTransform, Anchor.BottomCenter), sabotageButtonText)
            {
                OnClicked = (btn, obj) =>
                {
                    requestStartFixAction = FixActions.Sabotage;
                    item.CreateClientEvent(this);
                    return(true);
                }
            };

            foreach (XElement subElement in element.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
                case "emitter":
                case "particleemitter":
                    particleEmitters.Add(new ParticleEmitter(subElement));
                    particleEmitterConditionRanges.Add(new Vector2(
                                                           subElement.GetAttributeFloat("mincondition", 0.0f),
                                                           subElement.GetAttributeFloat("maxcondition", 100.0f)));
                    break;
                }
            }
        }