コード例 #1
0
            public ImmutableAttachmentInfo(MyObjectBuilder_EquiPlayerAttachmentComponentDefinition @base,
                                           MyObjectBuilder_EquiPlayerAttachmentComponentDefinition.AttachmentInfo ob)
            {
                Name               = ob.Name;
                Anchor             = ob.Anchor;
                _animations        = ob.Animations != null && ob.Animations.Length > 0 ? ob.Animations.Select(x => new AnimationDesc(x)).ToArray() : null;
                EmptyActionDesc    = (MyActionDescription)ob.EmptyAction;
                OccupiedActionDesc = (MyActionDescription)ob.OccupiedAction;
                _dummyNames.Clear();
                if (ob.DummyNames == null)
                {
                    return;
                }
                foreach (var d in ob.DummyNames)
                {
                    if (!string.IsNullOrWhiteSpace(d))
                    {
                        _dummyNames.Add(d);
                    }
                }

                var tmpOps = new List <ImmutableEffectOperations>();

                if (ob.EffectOperations != null)
                {
                    foreach (var eo in ob.EffectOperations)
                    {
                        var res = new ImmutableEffectOperations(eo);
                        if (res.IsValid)
                        {
                            tmpOps.Add(res);
                        }
                        else
                        {
                            MyDefinitionErrors.Add(@base.Package, $"{@base.Id} has an invalid effect operation", LogSeverity.Error);
                        }
                    }
                }

                EffectOperations = tmpOps;
            }
コード例 #2
0
            internal bool AssertValid(MyObjectBuilder_EquiPlayerAttachmentComponentDefinition parent)
            {
                var good = true;

                if (_operations.Count == 0)
                {
                    MyDefinitionErrors.Add(parent.Package, $"{parent.Id} has operation group with no operations", LogSeverity.Error);
                    good = false;
                }

                if (When == MyObjectBuilder_EquiPlayerAttachmentComponentDefinition.EffectOperationsInfo.TriggerTime.Continuous)
                {
                    if (IntervalMs <= 0)
                    {
                        MyDefinitionErrors.Add(parent.Package, $"{parent.Id} has operation group with continuous trigger and zero interval",
                                               LogSeverity.Error);
                        good = false;
                    }
                }
                else
                {
                    if (IntervalMs != 0)
                    {
                        MyDefinitionErrors.Add(parent.Package, $"{parent.Id} has operation group with non continuous trigger and non zero interval",
                                               LogSeverity.Error);
                        good = false;
                    }
                }

                // ReSharper disable once InvertIf
                if (When == MyObjectBuilder_EquiPlayerAttachmentComponentDefinition.EffectOperationsInfo.TriggerTime.Leave && DelayMs != 0)
                {
                    MyDefinitionErrors.Add(parent.Package, $"{parent.Id} has operation group with leave trigger and non zero delay", LogSeverity.Error);
                    good = false;
                }

                return(good);
            }
コード例 #3
0
            public ImmutableAttachmentInfo(MyObjectBuilder_EquiPlayerAttachmentComponentDefinition ob)
            {
                Name = LegacyAttachmentName;
                // ReSharper disable once PossibleInvalidOperationException
                Anchor      = ob.Anchor.Value;
                _animations = ob.Animations != null && ob.Animations.Length > 0 ? ob.Animations.Select(x => new AnimationDesc(x)).ToArray() : null;

                EmptyActionDesc    = (MyActionDescription)ob.EmptyAction;
                OccupiedActionDesc = (MyActionDescription)ob.OccupiedAction;
                _dummyNames.Clear();
                if (ob.DummyNames == null)
                {
                    return;
                }
                foreach (var d in ob.DummyNames)
                {
                    if (!string.IsNullOrWhiteSpace(d))
                    {
                        _dummyNames.Add(d);
                    }
                }

                EffectOperations = new List <ImmutableEffectOperations>();
            }