Esempio n. 1
0
        //F272_xxxx_SENSOR_TriggerEffect
        protected async void TriggerEffect(ILeader theron, ActuatorX actuator, SensorEffect effect)
        {
            if (LocalEffect)
            {
                TriggerLocalEffect(theron, actuator);
            }
            else
            {
                MessageAction action;
                switch (effect)
                {
                case SensorEffect.C00_EFFECT_SET:
                    action = MessageAction.Set;
                    break;

                case SensorEffect.C01_EFFECT_CLEAR:
                    action = MessageAction.Clear;
                    break;

                case SensorEffect.C02_EFFECT_TOGGLE:
                    action = MessageAction.Toggle;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(effect), effect, null);
                }

                //TODO send B,A,TargetCell only to wall tiles, floor tiles has set this flag NORTHWEST
                //TODO time delay await Task.Delay(A.Value);
                await Task.Delay(TimeDelay);

                TargetTile.AcceptMessageBase(new Message(action, Specifier));
            }
        }
Esempio n. 2
0
        protected override bool TryInteract(ILeader theron, WallActuator actuator, bool isLast, out bool L0753_B_DoNotTriggerSensor)
        {
            L0753_B_DoNotTriggerSensor = false;//Doesnt matter
            if (theron.Hand == null)
            {
                if ((theron.Hand = Storage) == null)
                {
                    return(false);
                }

                Storage = null;
            }
            else
            {
                if ((theron.Hand?.FactoryBase != Data) || Storage != null)
                {
                    return(false);
                }

                Storage     = theron.Hand;
                theron.Hand = null;
            }

            TriggerLocalEffect(theron, actuator, true); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
            if ((Effect == SensorEffect.C03_EFFECT_HOLD) && theron.Hand != null)
            {
                L0753_B_DoNotTriggerSensor = true;
            }
            else
            {
                L0753_B_DoNotTriggerSensor = false;
            }
            return(true);
        }
Esempio n. 3
0
        public override IRecord NewRecord(ILeader leader)
        {
            IRecord record = new Record();

            record.Leader = leader;
            return(record);
        }
Esempio n. 4
0
 public override IRecord NewRecord(ILeader leader)
 {
     return(new SortedRecord()
     {
         Leader = leader
     });
 }
Esempio n. 5
0
 internal static IList <WW.Math.Point3D> smethod_2(
     IList <WW.Math.Point3D> vertices,
     ILeader leader,
     out Vector3D startDerivative,
     out Vector3D endDerivative)
 {
     if (vertices != null && vertices.Count >= 2)
     {
         List <WW.Math.Point3D> point3DList = new List <WW.Math.Point3D>((IEnumerable <WW.Math.Point3D>)vertices);
         double   effectiveArrowSize        = leader.GetEffectiveArrowSize();
         Vector3D vector3D = point3DList[1] - point3DList[0];
         double   length   = vector3D.GetLength();
         startDerivative = vector3D / length;
         endDerivative   = leader.Direction;
         if (leader.HookLineDirection == HookLineDirection.Same)
         {
             endDerivative = -endDerivative;
         }
         endDerivative.Normalize();
         if (DxfLeader.smethod_7(leader, vertices) && leader.LeaderArrowBlock == null && length >= effectiveArrowSize)
         {
             point3DList[0] += vector3D * (effectiveArrowSize / length);
         }
         return((IList <WW.Math.Point3D>)point3DList);
     }
     startDerivative = endDerivative = Vector3D.Zero;
     return((IList <WW.Math.Point3D>)null);
 }
Esempio n. 6
0
        public override bool Interact(ILeader leader, ref Matrix currentTransformation, object param)
        {
            var ray      = (Ray)leader.Interactor;
            var distance = ray.Intersects(new BoundingBox(Tile.Position, Tile.Position + new Vector3(1f)));

            var  finalMatrix = GetCurrentTransformation(ref currentTransformation);
            bool res         = false;

            if (distance != null)
            {
                Tile.Renderer.Highlight(500);

                foreach (var tileSide in Tile.WallSides)
                {
                    if (tileSide.Renderer?.Interact(leader, ref finalMatrix, param) ?? false)
                    {
                        res = true;
                    }
                }
            }

            if (!Tile.IsOpen)
            {
                Tile.FloorSide.Renderer.Interact(leader, ref finalMatrix, param);
            }

            return(res);
        }
Esempio n. 7
0
        public override bool Interact(ILeader leader, ref Matrix currentTransformation, object param)
        {
            Matrix finalTransformation;

            Matrix.Multiply(ref transformation, ref currentTransformation, out finalTransformation);
            return(TileSide.Actuator.Renderer.Interact(leader, ref finalTransformation, param));
        }
 public override bool Interact(ILeader leader, ref Matrix currentTransformation, object param)
 {
     if (base.Interact(leader, ref currentTransformation, param))
     {
         Item.Trigger(leader);
         return(true);
     }
     return(false);;
 }
Esempio n. 9
0
 protected override bool TryInteract(ILeader theron, WallActuator actuator, bool isLast, out bool L0753_B_DoNotTriggerSensor)
 {
     L0753_B_DoNotTriggerSensor = false;
     if (Effect == SensorEffect.C03_EFFECT_HOLD)
     {
         return(false);
     }
     return(true);
 }
Esempio n. 10
0
 protected override bool TryInteract(ILeader theron, WallActuator actuator, bool isLast, out bool L0753_B_DoNotTriggerSensor)
 {
     L0753_B_DoNotTriggerSensor = ((Data == theron.Hand?.FactoryBase) == RevertEffect);
     if (!L0753_B_DoNotTriggerSensor)
     {
         theron.Hand = null;
     }
     return(true);;
 }
Esempio n. 11
0
        public bool Trigger(ILeader leader)
        {
            var jar = leader.Hand as IWaterJar;

            if (jar != null)
            {
                jar.Fill(Factories);
                return(true);
            }
            return(false);
        }
        public override bool Interact(ILeader leader, ref Matrix currentTransformation, object param)
        {
            bool decorationInteract = Actuator.SensorsEnumeration.LastOrDefault()?.GraphicsBase.Renderer.Interact(leader, ref currentTransformation, param) ?? false;

            if (decorationInteract)
            {
                Actuator.Trigger(leader);
            }

            return(decorationInteract);
        }
Esempio n. 13
0
        public override bool TryTrigger(ILeader theron, WallActuator actuator, bool isLast)
        {
            if (!Empty)
            {
                GameConsole.Instance?.RunCommand(new ChampionCommand {
                    Actuator = this
                });
                return(true);
            }

            return(base.TryTrigger(theron, actuator, isLast));
        }
Esempio n. 14
0
 //F270_xxxx_SENSOR_TriggerLocalEffect
 protected void TriggerLocalEffect(ILeader theron, ActuatorX actuator, bool?rotate = null)
 {
     if (ExperienceGain)
     {
         //TODO on floor tiles add skill to all party members
         AddExperience(theron, SkillFactory <StealSkill> .Instance, 300, true /*P574_i_SensorLocalEffectCell != CM1_CELL_ANY*/);
     }
     else if (rotate ?? Rotate)
     {
         actuator.Rotate = Rotate;
     }
 }
Esempio n. 15
0
 protected void WriteLeader(ILeader ldr)
 {
     output.Write(encoding.GetBytes(ldr.RecordLength.ToString().PadLeft(5, '0')));
     output.Write(ldr.RecordStatus);
     output.Write(ldr.TypeOfRecord);
     output.Write(encoding.GetBytes(new String(ldr.ImplDefined1)));
     output.Write(ldr.CharCodingScheme);
     output.Write(encoding.GetBytes(ldr.IndicatorCount.ToString()));
     output.Write(encoding.GetBytes(ldr.SubfieldCodeLength.ToString()));
     output.Write(encoding.GetBytes(ldr.BaseAddressOfData.ToString().PadLeft(5, '0')));
     output.Write(encoding.GetBytes(new String(ldr.ImplDefined2)));
     output.Write(encoding.GetBytes(new String(ldr.EntryMap)));
 }
Esempio n. 16
0
        public bool Trigger(ILeader leader)
        {
            bool anyTriggered = false;

            foreach (var sensor in Sensors)
            {
                bool sensorTrigger = sensor.TryTrigger(leader, this, sensor == Sensors.Last());
                anyTriggered = anyTriggered || sensorTrigger;
            }

            ProcessRotationEffect(Sensors);
            return(anyTriggered);
        }
Esempio n. 17
0
 public virtual bool Trigger(ILeader leader)
 {
     if (leader.Hand == null && items.Any())
     {
         leader.Hand = items.Pop();
     }
     else if (leader.Hand != null)
     {
         items.Push(leader.Hand);
         leader.Hand = null;
     }
     return(true);
 }
Esempio n. 18
0
        internal static void smethod_4(
            DrawContext context,
            ILineTypeScaler lineTypeScaler,
            ILeader leader,
            IList <WW.Math.Point3D> vertices,
            DxfLineType lineType,
            Vector3D zAxis,
            double lineTypeScale,
            out IList <Polyline3D> polylines,
            out IList <FlatShape4D> shapes)
        {
            Polyline3D polyline = DxfLeader.smethod_3(context, leader, vertices);

            if (context.Config.ApplyLineType)
            {
                polylines = (IList <Polyline3D>) new List <Polyline3D>();
                if (polyline != null)
                {
                    shapes = (IList <FlatShape4D>) new List <FlatShape4D>();
                    DxfUtil.smethod_4(context.Config, polylines, shapes, polyline, lineType, zAxis, context.TotalLineTypeScale * lineTypeScale, lineTypeScaler);
                    if (shapes.Count != 0)
                    {
                        return;
                    }
                    shapes = (IList <FlatShape4D>)null;
                }
                else
                {
                    shapes = (IList <FlatShape4D>)null;
                }
            }
            else
            {
                ref IList <Polyline3D> local = ref polylines;
                List <Polyline3D>      polyline3DList;
                if (polyline == null)
                {
                    polyline3DList = new List <Polyline3D>();
                }
                else
                {
                    polyline3DList = new List <Polyline3D>()
                    {
                        polyline
                    }
                };
                local  = (IList <Polyline3D>)polyline3DList;
                shapes = (IList <FlatShape4D>)null;
            }
        }
Esempio n. 19
0
        protected override bool TryInteract(ILeader theron, WallActuator actuator, bool isLast, out bool L0753_B_DoNotTriggerSensor)
        {
            if (!base.TryInteract(theron, actuator, isLast, out L0753_B_DoNotTriggerSensor))
            {
                return(false);
            }
            ;

            if (!L0753_B_DoNotTriggerSensor)
            {
                TriggerLocalEffect(theron, actuator, true); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
            }
            return(true);
        }
Esempio n. 20
0
 private void ParseLeader(ILeader ldr, byte[] leaderData)
 {
     using (var isr = new StreamReader(new MemoryStream(leaderData), Encoding.GetEncoding("ISO-8859-1")))
     {
         char[] tmp = new char[5];
         isr.Read(tmp, 0, tmp.Length);
         //  Skip over bytes for record length, If we get here, its already been computed.
         ldr.RecordStatus = (char)isr.Read();
         ldr.TypeOfRecord = (char)isr.Read();
         tmp = new char[2];
         isr.Read(tmp, 0, tmp.Length);
         ldr.ImplDefined1     = tmp;
         ldr.CharCodingScheme = (char)isr.Read();
         char   indicatorCount     = (char)isr.Read();
         char   subfieldCodeLength = (char)isr.Read();
         char[] baseAddr           = new char[5];
         isr.Read(baseAddr, 0, baseAddr.Length);
         tmp = new char[3];
         isr.Read(tmp, 0, tmp.Length);
         ldr.ImplDefined2 = tmp;
         tmp = new char[4];
         isr.Read(tmp, 0, tmp.Length);
         ldr.EntryMap = tmp;
         isr.Close();
         try
         {
             ldr.IndicatorCount = int.Parse(indicatorCount.ToString());
         }
         catch (FormatException e)
         {
             throw new MarcException("unable to parse indicator count", e);
         }
         try
         {
             ldr.SubfieldCodeLength = int.Parse(subfieldCodeLength.ToString());
         }
         catch (FormatException e)
         {
             throw new MarcException("unable to parse subfield code length", e);
         }
         try
         {
             ldr.BaseAddressOfData = int.Parse(new String(baseAddr));
         }
         catch (FormatException e)
         {
             throw new MarcException("unable to parse base address of data", e);
         }
     }
 }
Esempio n. 21
0
        protected override bool TryInteract(ILeader theron, WallActuator actuator, bool isLast, out bool L0753_B_DoNotTriggerSensor)
        {
            if (!base.TryInteract(theron, actuator, isLast, out L0753_B_DoNotTriggerSensor))
                return false;

            if (!L0753_B_DoNotTriggerSensor)
            {
                if (actuator.Sensors.Count == 1)
                    return true;

                actuator.Sensors.Remove(this);
            }
            return true;
        }
Esempio n. 22
0
        internal static Polyline3D smethod_5(ILeader leader)
        {
            if (!leader.ArrowHeadEnabled || leader.ArrowSize <= 0.0)
            {
                return((Polyline3D)null);
            }
            Polyline3D polyline3D = new Polyline3D(3);
            double     y          = 1.0 / 6.0;

            polyline3D.Add(WW.Math.Point3D.Zero);
            polyline3D.Add(new WW.Math.Point3D(-1.0, y, 0.0));
            polyline3D.Add(new WW.Math.Point3D(-1.0, -1.0 / 6.0, 0.0));
            polyline3D.Closed = true;
            return(polyline3D);
        }
Esempio n. 23
0
        internal static Matrix4D smethod_6(
            ILeader leader,
            IList <WW.Math.Point3D> vertices,
            Vector3D zaxis)
        {
            WW.Math.Point3D vertex1        = vertices[0];
            WW.Math.Point3D vertex2        = vertices[1];
            Matrix4D        toWcsTransform = DxfUtil.GetToWCSTransform(zaxis);
            Vector3D        v1             = new Vector3D(toWcsTransform.M00, toWcsTransform.M10, toWcsTransform.M20);
            Vector3D        v2             = new Vector3D(toWcsTransform.M01, toWcsTransform.M11, toWcsTransform.M21);
            Vector3D        u     = vertex1 - vertex2;
            double          angle = System.Math.Atan2(Vector3D.DotProduct(u, v2), Vector3D.DotProduct(u, v1));
            double          effectiveArrowSize = leader.GetEffectiveArrowSize();

            return(Transformation4D.Translation((Vector3D)vertex1) * toWcsTransform * Transformation4D.RotateZ(angle) * Transformation4D.Scaling(effectiveArrowSize, effectiveArrowSize, effectiveArrowSize));
        }
Esempio n. 24
0
        //Vector3.Transform( Resource.BoundingBox.Min, GetCurrentTransformation(ref currentTransformation))
        //1,35  -0,15  14,505
        //    X: 1.35
        //    Y: -0.15
        //    Z: 14.505
        //Resource.BoundingBox.Min
        //-0,5  -0,5  -0,05
        //    X: -0.5
        //    Y: -0.5
        //    Z: -0.05
        //Resource.BoundingBox.Max
        //0,5  0,5  0
        //    X: 0.5
        //    Y: 0.5
        //    Z: 0

        public override bool Interact(ILeader leader, ref Matrix currentTransformation, object param)
        {
            Matrix finalTransformationinerse = Matrix.Invert(GetCurrentTransformation(ref currentTransformation));
            var    ray = (Ray)leader.Interactor;

            var transform = ray.Transform(ref finalTransformationinerse);
            var res       = Resource.BoundingBox.Intersects(transform);

            if (res != null)
            {
                Highlight(500);
                return(true);
            }

            return(false);
        }
Esempio n. 25
0
        protected override bool TryInteract(ILeader theron, WallActuator actuator, bool isLast, out bool L0753_B_DoNotTriggerSensor)
        {
            L0753_B_DoNotTriggerSensor = false;//Doesnt matter
            if (!isLast)
            {
                return(false);
            }

            L0753_B_DoNotTriggerSensor = theron.Hand != null;
            if (!L0753_B_DoNotTriggerSensor)
            {
                TriggerLocalEffect(theron, actuator, true); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
                theron.Hand = Data.CreateItem();
            }
            return(true);
        }
Esempio n. 26
0
        internal static bool smethod_7(ILeader leader, IList <WW.Math.Point3D> vertices)
        {
            if (!leader.ArrowHeadEnabled || leader.ArrowSize <= 0.0)
            {
                return(false);
            }
            bool flag = false;

            if (vertices.Count >= 2)
            {
                WW.Math.Point3D vertex             = vertices[0];
                double          lengthSquared      = (vertices[1] - vertex).GetLengthSquared();
                double          effectiveArrowSize = leader.GetEffectiveArrowSize();
                flag = effectiveArrowSize * effectiveArrowSize <= 0.25 * lengthSquared + 8.88178419700125E-16;
            }
            return(flag);
        }
Esempio n. 27
0
        public IRecord Next()
        {
            IRecord rec      = reader.Current;
            ILeader l        = rec.Leader;
            bool    is_utf_8 = false;

            if (l.CharCodingScheme == 'a')
            {
                is_utf_8 = true;
            }
            if (is_utf_8 && unicodeNormalize == NormalizationForm.FormC)
            {
                return(rec);
            }
            var fields = rec.GetVariableFields();

            foreach (var f in fields)
            {
                if (!(f is IDataField))
                {
                    continue;
                }
                var field     = (IDataField)f;
                var subfields = field.GetSubfields();
                foreach (var sf in subfields)
                {
                    String oldData = sf.Data;
                    String newData = oldData;
                    if (!is_utf_8)
                    {
                        newData = convert.Convert(newData);
                    }
                    if (unicodeNormalize != NormalizationForm.FormC)
                    {
                        newData = newData.Normalize(unicodeNormalize);
                    }
                    if (!oldData.Equals(newData))
                    {
                        sf.Data = newData;
                    }
                }
            }
            l.CharCodingScheme = 'a';
            rec.Leader         = l;
            return(rec);
        }
        public override bool Interact(ILeader leader, ref Matrix currentTransformation, object param)
        {
            Ray ray = (Ray)leader.Interactor;
            var resultTransformationInverse = Matrix.Invert(GetCurrentTransformation(ref currentTransformation));

            foreach (var space in TileSide.Spaces)
            {
                var p = GetBoundingBox(space.RelativeGridPosition);
                var transformedRay = ray.Transform(ref resultTransformationInverse);
                if (transformedRay.Intersects(p) != null)
                {
                    return(space.Trigger(leader));
                }
            }

            return(false);
        }
Esempio n. 29
0
        public bool Trigger(ILeader leader)
        {
            if (leader.Hand == null && items.Any())
            {
                leader.Hand = RemoveItem(items.Last());
                leader.Hand.SetLocationNoEvents(null);
                return(true);
            }
            else if (leader.Hand != null)
            {
                leader.Hand.SetLocationNoEvents(Layout.GetSpaceElement(Space, leader.Location.Tile));
                AddItem(leader.Hand);
                leader.Hand = null;
                return(true);
            }

            return(false);
        }
Esempio n. 30
0
        public static string[] Traits(this ILeader leader)
        {
            List <string> output = new List <string>();

            if (leader.Aggression != AggressionLevel.Normal)
            {
                output.Add(leader.Aggression.ToText());
            }
            if (leader.Development != DevelopmentLevel.Normal)
            {
                output.Add(leader.Development.ToString());
            }
            if (leader.Militarism != MilitarismLevel.Normal)
            {
                output.Add(leader.Militarism.ToString());
            }
            return(output.ToArray());
        }