Inheritance: MonoBehaviour
コード例 #1
0
ファイル: Wrapper.cs プロジェクト: afrog33k/mcocoa
    public static Wrapper Create(object value)
    {
        Wrapper result = new Wrapper(value);
        result.autorelease();

        return result;
    }
コード例 #2
0
ファイル: MagickGeometry.cs プロジェクト: levesque/Magick.NET
    internal static MagickGeometry Create(Wrapper.MagickGeometry value)
    {
      if (value == null)
        return null;

      return new MagickGeometry(value);
    }
コード例 #3
0
		public CodeExpression GenerateNewInstanceCode (Wrapper.Widget widget)
		{
			CodeExpression exp = widget.GenerateObjectCreation (this);
			CodeExpression var = GenerateInstanceExpression (widget, exp);
			GenerateBuildCode (widget, var);
			return var;
		}
 public Gradient3ColorsViewModel()
 {
     Func<object, Tuple<bool, double>> converter = (o) => Tuple.Create(o.IsDouble(), o.ToDouble());
     LowValue = new Wrapper<double>(converter);
     MidValue = new Wrapper<double>(converter);
     HighValue = new Wrapper<double>(converter);
 }
コード例 #5
0
ファイル: GameController.cs プロジェクト: gan3ma/Client
 //Dictionary<string, string> p = new Dictionary<string, string>{ {"name" , "gan3ma2"} , {"room_no" , "252"} };
 //Dictionary<string, string> t = new Dictionary<string, string>{ {"play_id" , "7"} , {"user_id" , "38"}};
 // Use this for initialization
 void Start()
 {
     W = GameObject.Find ("Wrapper").GetComponent<Wrapper> ();
     //p ["name"] = "gan3ma";
     url = "http://192.168.3.83:3000/plays/7/pieces";
     W.GET (url);
 }
コード例 #6
0
 public JTreeStringTemplateModel(StringTemplate st)
 {
     if (st == null)
     {
         throw new System.ArgumentException("root is null");
     }
     root = new StringTemplateWrapper(st);
 }
コード例 #7
0
ファイル: Issue192.cs プロジェクト: GeorchW/protobuf-net
 public void SerializeWrappedDeepList()
 {
     Program.ExpectFailure<NotSupportedException>(() =>
     {
         var wrapped = new Wrapper();
         var clone = Serializer.DeepClone(wrapped);
     }, "Nested or jagged lists and arrays are not supported");
 }
コード例 #8
0
 public void SetUp()
 {
     node1 = new Wrapper(typeof(FakeJsonBehavior));
     node2 = new Wrapper(typeof(FakeJsonBehavior));
     node3 = new Wrapper(typeof(FakeJsonBehavior));
     node1.AddToEnd(node2);
     node1.AddToEnd(node3);
 }
コード例 #9
0
 static bool IsRemoved(Wrapper wrapper)
 {
     if (!wrapper.body.IsAdded)
     {
         wrapper.Dispose();
         return true;
     }
     return false;
 }
コード例 #10
0
        public void append_with_no_behaviors()
        {
            var chain = new BehaviorChain();
            var wrapper = new Wrapper(typeof (ObjectDefInstanceTester.FakeJsonBehavior));

            chain.Append(wrapper);

            chain.Top.ShouldBeTheSameAs(wrapper);
        }
        public void creating_an_object_def_for_full_tracing_should_wrap_with_a_behavior_tracer()
        {
            var node = new Wrapper(typeof(SimpleBehavior));
            var objectDef = new BehaviorTracerNode(node).As<IContainerModel>().ToObjectDef();

            objectDef.Type.ShouldEqual(typeof(BehaviorTracer));
            objectDef.DependencyFor<IActionBehavior>().As<ConfiguredDependency>()
                .Definition.Type.ShouldEqual(typeof(SimpleBehavior));
        }
コード例 #12
0
        public void Simple(IObjectMapperAdapter mapper)
        {
            mapper.CreateMap<Wrapper<string>, ImmutableWrapper<string>>();

            var source = new Wrapper<string> { Value = "X" };
            var result = mapper.Map<ImmutableWrapper<string>>(source);

            Assert.Equal("X", result.Value);
        }
        public void creating_an_object_def_for_full_tracing_should_wrap_with_a_behavior_tracer()
        {
            var node = new Wrapper(typeof (SimpleBehavior));
            var instance = new BehaviorTracerNode(node).As<IContainerModel>().ToInstance().As<IConfiguredInstance>();

            instance.PluggedType.ShouldBe(typeof (BehaviorTracer));
            instance.FindDependencyDefinitionFor<IActionBehavior>()
                .ReturnedType.ShouldBe(typeof (SimpleBehavior));
        }
コード例 #14
0
ファイル: CodeGenerator.cs プロジェクト: mono/stetic
 public static WidgetMap GenerateCreationCode(CodeNamespace cns, CodeTypeDeclaration type, Wrapper.ActionGroup grp, CodeExpression groupVarExp, CodeStatementCollection statements, GenerationOptions options, ArrayList warnings)
 {
     statements.Add (new CodeCommentStatement ("Action group " + grp.Name));
     GeneratorContext ctx = new ProjectGeneratorContext (cns, type, statements, options);
     ctx.GenerateCreationCode (grp, groupVarExp);
     ctx.EndGeneration ();
     warnings.AddRange (ctx.Warnings);
     return ctx.WidgetMap;
 }
コード例 #15
0
        public void SetUp()
        {
            inner = Wrapper.For<SimpleBehavior>();
            chain = new BehaviorChain();

            chain.AddToEnd(inner);

            theNode = new BehaviorTracerNode(inner);
        }
コード例 #16
0
        public void SetUp()
        {
            inner = Wrapper.For<SimpleBehavior>();
            chain = new BehaviorChain();

            chain.AddToEnd(inner);

            theNode = new DiagnosticNode(chain);
        }
コード例 #17
0
ファイル: BehaviorChainTester.cs プロジェクト: hartez/fubumvc
        public void adding_a_node_to_the_end_sets_the_chain_on_the_node()
        {
            var chain = new BehaviorChain();
            var wrapper = new Wrapper(typeof(ObjectDefInstanceTester.FakeJsonBehavior));

            chain.AddToEnd(wrapper);

            wrapper.ParentChain().ShouldBeTheSameAs(chain);
        }
コード例 #18
0
        public void PropertyToDictionaryEntry(IObjectMapperAdapter mapper)
        {
            mapper.CreateMap<Wrapper<string>, Dictionary<string, object>>();

            var source = new Wrapper<string> { Value = "ABC" };
            var result = mapper.Map<Dictionary<string, object>>(source);

            Assert.NotNull(result);
            Assert.Contains(new KeyValuePair<string, object>("Value", "ABC"), result);
        }
コード例 #19
0
            public static BaseEvent CreateWrapper(BaseEvent original, Action<BaseEvent, bool> passthrough, bool ignore_delay)
            {
                ConfigNode cn = new ConfigNode();
                original.OnSave(cn);
                Wrapper wrapper = new Wrapper(original, passthrough, ignore_delay);
                BaseEvent new_event = new BaseEvent(original.listParent, original.name, wrapper.Invoke);
                new_event.OnLoad(cn);

                return new_event;
            }
コード例 #20
0
        public IAsyncResult Enqueue(object request, AsyncCallback callback, object state)
        {
            var wrapper = new Wrapper(callback, state);
            lock (_items)
            {
                _items.Add(request, wrapper);
            }

            return wrapper;
        }
コード例 #21
0
        internal static void Serialize(string filename, List<Model.Database> databases)
        {
            Wrapper wrapper = new Wrapper(FileVersionLatest, databases);
            BinaryFormatter formatter = new BinaryFormatter();

            using (Stream stream = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                formatter.Serialize(stream, wrapper);
                stream.Close();
            }
        }
コード例 #22
0
 public void Configure(FubuRegistry registry)
 {
     registry.Configure(graph =>
     {
         graph.Behaviors.Where(PassportConfiguration.RestrictedAction).Each(c =>
         {
             var x = new Wrapper(typeof (AuthenticationPolicy));
             c.Prepend(x);
         });
     });
 }
コード例 #23
0
ファイル: Client.cs プロジェクト: Rawwar13/YAMS
        public Client(Socket sktClient, Wrapper.Listen listener)
        {
            this.ip = ((IPEndPoint)sktClient.RemoteEndPoint).Address;

            this.shouter = new Wrapper.Shout();
            sktClient.SendTimeout = 10000;
            sktClient.ReceiveTimeout = 10000;

            //Woo a legit client, let's add them to our list
            listener.Clients.Add(this);
        }
コード例 #24
0
            public static BaseEvent Wrap(BaseEvent original, Action<BaseEvent> passthrough)
            {
                ConfigNode cn = new ConfigNode();
                original.OnSave(cn);
                Wrapper wrapper = new Wrapper(original, passthrough);
                BaseEvent new_event = new BaseEvent(original.listParent, original.name,
                                                                         wrapper.Invoke);
                new_event.OnLoad(cn);

                return new_event;
            }
コード例 #25
0
        public void prepend_with_an_existing_top_behavior()
        {
            var chain = new BehaviorChain();
            ActionCall call = ActionCall.For<TestController>(x => x.AnotherAction(null));
            chain.Append(call);

            var wrapper = new Wrapper(typeof (ObjectDefInstanceTester.FakeJsonBehavior));
            chain.Prepend(wrapper);

            chain.Top.ShouldBeTheSameAs(wrapper);
            wrapper.Next.ShouldBeTheSameAs(call);
        }
コード例 #26
0
		public void UncontentionedFailingMCas()
		{
			Wrapper one = new Wrapper();
			one.Value = 1;
			Wrapper[] expected = new Wrapper[] { null, one, null };
			Wrapper[] newVals = new Wrapper[] { null, null, one };
			
			Assert.IsFalse(InterlockedEx.MultiCompareAndSwap(locations, expected, newVals), "#1");
			Assert.AreEqual(null, val3.Value, "#2");
			Assert.AreEqual(null, val2.Value, "#3");
			Assert.AreEqual(null, val1.Value, "#4");
		}
コード例 #27
0
 private Wrapper DFS(TreeAndGraph.BinaryTreeNode head)
 {
     Wrapper wr = new Wrapper();
     if (head == null)
     {
         return wr;
     }
     Wrapper l = DFS(head.LeftNode);
     Wrapper r = DFS(head.RightNode);
     wr.BranchLen = Math.Max(l.BranchLen, r.BranchLen) + (int)head.Data;
     wr.LoopLen = Math.Max(Math.Max(l.LoopLen, r.LoopLen), l.BranchLen + r.BranchLen + (int)head.Data);
     return wr;
 }
コード例 #28
0
ファイル: ValidateName.cs プロジェクト: Stewartarmbrecht/xBDD
        internal static Step ValidatesTheWidget(Wrapper<Widget> widget, Wrapper<WidgetValidator> validator, Wrapper<Exception> exception)
        {
            return xB.CreateStep("the user validates the widget", (s) => {
				try 
				{
					validator.Object.ValidateWidget(widget.Object);
				}
				catch(Exception ex)
				{
					exception.Object = ex;
				}
			});
        }
コード例 #29
0
ファイル: TypeErasure.cs プロジェクト: ufcpp/UfcppSample
        static void Main(string[] args)
        {
            var i = new Wrapper { Value = new Integer(1) };
            var b = new Wrapper { Value = new Byte(1) };
            var s = new Wrapper { Value = "abc" };
            var a = new Wrapper { Value = new[] { 1, 2, 3 } };

            // キャストが必要
            int iv = ((Integer)i.Value).Value;
            byte bv = ((Byte)i.Value).Value;
            string sv = (string)s.Value;
            int[] av = (int[])a.Value;
        }
コード例 #30
0
        public void enrich_puts_the_new_chain_node_directly_behind_the_call()
        {
            action = ActionCall.For<ControllerTarget>(x => x.OneInOneOut(null));
            var next = new RenderJsonNode(typeof (Model2));

            action.AddToEnd(next);

            var enricher = new Wrapper(typeof (string));
            action.AddAfter(enricher);

            action.Next.ShouldBeTheSameAs(enricher);
            enricher.Next.ShouldBeTheSameAs(next);
        }
コード例 #31
0
 public NonOverridableClassCppProducer(MetaDefinition metaDef, Wrapper wrapper, ClassDefinition t, SourceCodeStringBuilder sb)
     : base(metaDef, wrapper, t, sb)
 {
 }
コード例 #32
0
ファイル: JsonObject.cs プロジェクト: robin1392/robin
        public static T[] DeserializeArray <T>(string json)
        {
            Wrapper <T> wrapper = JsonUtility.FromJson <Wrapper <T> >(json);

            return(wrapper.Items);
        }
コード例 #33
0
 public Task <long> PublishAsync(string channelName, IPubSubMessage message, CommandFlags flags = CommandFlags.None) => Wrapper.Subscriber.Value.PublishAsync(GetRealChannelName(channelName), Wrapper.Wrap(message), flags);
コード例 #34
0
ファイル: MsgEncoder.cs プロジェクト: zhanjian/akka.net
        public void Encode(IConnection connection, object message, out List <IByteBuf> encoded)
        {
            encoded = new List <IByteBuf>();
            var x = message as INetworkOp;

            if (x != null)
            {
                var w = Wrapper.CreateBuilder();
                x.Match()
                .With <Hello>(
                    hello =>
                    w.SetHello(
                        TCP.Hello.CreateBuilder()
                        .SetName(hello.Name)
                        .SetAddress(Address2Proto(hello.Address))))
                .With <EnterBarrier>(barrier =>
                {
                    var protoBarrier = TCP.EnterBarrier.CreateBuilder().SetName(barrier.Name);
                    if (barrier.Timeout.HasValue)
                    {
                        protoBarrier.SetTimeout(barrier.Timeout.Value.Ticks);
                    }
                    protoBarrier.SetOp(BarrierOp.Enter);
                    w.SetBarrier(protoBarrier);
                })
                .With <BarrierResult>(result =>
                {
                    var res = result.Success ? BarrierOp.Succeeded : BarrierOp.Failed;
                    w.SetBarrier(
                        TCP.EnterBarrier.CreateBuilder().SetName(result.Name).SetOp(res));
                })
                .With <FailBarrier>(
                    barrier =>
                    w.SetBarrier(TCP.EnterBarrier.CreateBuilder()
                                 .SetName(barrier.Name)
                                 .SetOp(BarrierOp.Fail)))
                .With <ThrottleMsg>(
                    throttle =>
                {
                    w.SetFailure(
                        InjectFailure.CreateBuilder()
                        .SetFailure(TCP.FailType.Throttle)
                        .SetAddress(Address2Proto(throttle.Target))
                        .SetFailure(TCP.FailType.Throttle)
                        .SetDirection(Direction2Proto(throttle.Direction))
                        .SetRateMBit(throttle.RateMBit));
                })
                .With <DisconnectMsg>(
                    disconnect =>
                    w.SetFailure(
                        InjectFailure.CreateBuilder()
                        .SetAddress(Address2Proto(disconnect.Target))
                        .SetFailure(disconnect.Abort ? TCP.FailType.Abort : TCP.FailType.Disconnect)))
                .With <TerminateMsg>(terminate =>
                {
                    if (terminate.ShutdownOrExit.IsRight)
                    {
                        w.SetFailure(
                            InjectFailure.CreateBuilder()
                            .SetFailure(TCP.FailType.Exit)
                            .SetExitValue(terminate.ShutdownOrExit.ToRight().Value));
                    }
                    else if (terminate.ShutdownOrExit.IsLeft && !terminate.ShutdownOrExit.ToLeft().Value)
                    {
                        w.SetFailure(
                            InjectFailure.CreateBuilder()
                            .SetFailure(TCP.FailType.Shutdown));
                    }
                    else
                    {
                        w.SetFailure(
                            InjectFailure.CreateBuilder()
                            .SetFailure(TCP.FailType.ShutdownAbrupt));
                    }
                })
                .With <GetAddress>(
                    address => w.SetAddr(AddressRequest.CreateBuilder().SetNode(address.Node.Name)))
                .With <AddressReply>(
                    reply =>
                    w.SetAddr(
                        AddressRequest.CreateBuilder()
                        .SetNode(reply.Node.Name)
                        .SetAddr(Address2Proto(reply.Addr))))
                .With <Done>(done => w.SetDone(string.Empty))
                .Default(obj => w.SetDone(string.Empty));

                encoded.Add(connection.Allocator.Buffer().WriteBytes(w.Build().ToByteArray()));
            }
            else
            {
                throw new ArgumentException(string.Format("wrong message {0}", message));
            }
        }
コード例 #35
0
        public override bool HandleCommand(ulong userId, string[] words)
        {
            lock (Docking.Instance)
            {
                foreach (DockingItem dockingItem in Docking.Instance.DockingItems)
                {
                    string dockedShipFileName = Essentials.PluginPath + String.Format("\\Docking\\docked_{0}_{1}_{2}.sbc", dockingItem.PlayerId, dockingItem.TargetEntityId, dockingItem.DockedEntityId);

                    DockingItem dockedShip = dockingItem;
                    IMyEntity   entity     = MyAPIGateway.Entities.GetEntity(x => x.EntityId == dockedShip.TargetEntityId && x is IMyCubeGrid);
                    if (entity == null)
                    {
                        //Communication.SendPrivateInformation(userId, string.Format("Unable to undock ship due to error."));
                        Log.Info(string.Format("Unable to find parent '{0}' for '{1}' - '{2}'", dockingItem.TargetEntityId, dockingItem.DockedEntityId, dockingItem.DockedName));
                        //continue;
                    }

                    if (!File.Exists(dockedShipFileName))
                    {
                        Log.Info(string.Format("Unable to find ship file: {0}", dockedShipFileName));
                        continue;
                    }

//					FileInfo fileInfo = new FileInfo(dockedShipFileName);
                    MyObjectBuilder_CubeGrid cubeGrid;
                    MyObjectBuilderSerializer.DeserializeXML(dockedShipFileName, out cubeGrid);

                    if (entity != null)
                    {
                        // Rotate our ship relative to our saved rotation and the new carrier rotation
                        cubeGrid.PositionAndOrientation = new MyPositionAndOrientation(Matrix.CreateFromQuaternion(Quaternion.CreateFromRotationMatrix(entity.Physics.GetWorldMatrix().GetOrientation()) * dockingItem.SaveQuat).GetOrientation());
                        // Move our ship relative to the new carrier position and orientation
                        Quaternion newQuat    = Quaternion.CreateFromRotationMatrix(entity.Physics.GetWorldMatrix().GetOrientation());
                        Vector3D   rotatedPos = Vector3D.Transform(dockingItem.SavePos, newQuat);
                        //cubeGrid.Position = rotatedPos + parent.GetPosition();
                        cubeGrid.PositionAndOrientation = new MyPositionAndOrientation(MathUtility.RandomPositionFromPoint(entity.GetPosition(), 250f), cubeGrid.PositionAndOrientation.Value.Forward, cubeGrid.PositionAndOrientation.Value.Up);
                    }
                    else
                    {
                        cubeGrid.PositionAndOrientation = new MyPositionAndOrientation(MathUtility.RandomPositionFromPoint(cubeGrid.PositionAndOrientation.Value.Position, 500f), cubeGrid.PositionAndOrientation.Value.Forward, cubeGrid.PositionAndOrientation.Value.Up);
                    }

                    // Add object to world
                    cubeGrid.EntityId        = BaseEntity.GenerateEntityId();
                    cubeGrid.LinearVelocity  = Vector3.Zero;
                    cubeGrid.AngularVelocity = Vector3.Zero;

                    bool undock = false;
                    Wrapper.GameAction(() =>
                    {
                        try
                        {
                            IMyEntity newEntity = MyAPIGateway.Entities.CreateFromObjectBuilderAndAdd(cubeGrid);
                            MyMultiplayer.ReplicateImmediatelly(MyExternalReplicable.FindByObject(newEntity));
                            undock = true;
                        }
                        catch (Exception ex)
                        {
                            Log.Info(string.Format("Error undocking ship: {0}", ex.ToString()));
                            Communication.SendPrivateInformation(userId, string.Format("Unable to undock ship due to error."));
                        }
                    });

                    if (!undock)
                    {
                        return(true);
                    }

                    File.Delete(dockedShipFileName);
                    Communication.SendPrivateInformation(userId, string.Format("The ship '{0}' has been undocked from docking zone", dockingItem.DockedName));
                }

                Docking.Instance.DockingItems.Clear();
                Docking.Instance.Save();
            }

            return(true);
        }
コード例 #36
0
    public void ExternalDependencyFound()
    {
        dynamic d = new Wrapper();

        d.TestMethodSuffix();
    }
コード例 #37
0
        static public void RevealAll()
        {
            HashSet <IMyEntity> entities = new HashSet <IMyEntity>();

            Wrapper.GameAction(() =>
            {
                MyAPIGateway.Entities.GetEntities(entities);
            });

            List <MyObjectBuilder_EntityBase> addList = new List <MyObjectBuilder_EntityBase>();
            int count = 0;

            Wrapper.GameAction(() =>
            {
                foreach (IMyEntity entity in entities)
                {
                    if (entity.InScene)
                    {
                        continue;
                    }

                    if (!(entity is IMyCubeGrid))
                    {
                        continue;
                    }

                    MyObjectBuilder_CubeGrid builder = CubeGrids.SafeGetObjectBuilder((IMyCubeGrid)entity);
                    if (builder == null)
                    {
                        continue;
                    }

                    count++;
                    IMyCubeGrid grid = (IMyCubeGrid)entity;
                    long ownerId     = 0;
                    string ownerName = "";
                    if (CubeGrids.GetBigOwners(builder).Count > 0)
                    {
                        ownerId   = CubeGrids.GetBigOwners(builder).First();
                        ownerName = PlayerMap.Instance.GetPlayerItemFromPlayerId(ownerId).Name;
                    }

                    //grid.PersistentFlags = (MyPersistentEntityFlags2.InScene | MyPersistentEntityFlags2.CastShadows);
                    //grid.InScene = true;
                    //grid.CastShadows = true;
                    builder.PersistentFlags = (MyPersistentEntityFlags2.InScene | MyPersistentEntityFlags2.CastShadows);
                    MyAPIGateway.Entities.RemapObjectBuilder(builder);
                    Logging.WriteLineAndConsole("Conceal", string.Format("Force Revealing - Id: {0} -> {4} Display: {1} OwnerId: {2} OwnerName: {3}", entity.EntityId, entity.DisplayName.Replace("\r", "").Replace("\n", ""), ownerId, ownerName, builder.EntityId));

                    IMyEntity newEntity = MyAPIGateway.Entities.CreateFromObjectBuilder(builder);
                    if (newEntity == null)
                    {
                        Logging.WriteLineAndConsole("Conceal", string.Format("Issue - CreateFromObjectBuilder failed: {0}", newEntity.EntityId));
                        continue;
                    }

                    BaseEntityNetworkManager.BroadcastRemoveEntity(entity, false);
                    MyAPIGateway.Entities.AddEntity(newEntity, true);
                    addList.Add(newEntity.GetObjectBuilder());
                    MyAPIGateway.Multiplayer.SendEntitiesCreated(addList);
                    addList.Clear();
                }
            });

            Logging.WriteLineAndConsole(string.Format("Revealed {0} grids", count));
        }
コード例 #38
0
 public Task <string> GetAsync(string key, CommandFlags flags = CommandFlags.None) => Wrapper.UnwrapAsync <string>(() => Wrapper.Database.StringGetAsync(Wrapper.GetRealKey(key), flags));
コード例 #39
0
 public string Get(string key, CommandFlags flags = CommandFlags.None) => Wrapper.Unwrap <string>(() => Wrapper.Database.StringGet(Wrapper.GetRealKey(key), flags));
コード例 #40
0
        public override bool HandleCommand(ulong userId, string[] words)
        {
            bool force = words.FirstOrDefault(x => x.ToLower() == "force") != null;

            HashSet <IMyEntity> entities = new HashSet <IMyEntity>();

            Wrapper.GameAction(() => MyAPIGateway.Entities.GetEntities(entities));

            List <MyObjectBuilder_EntityBase> addList = new List <MyObjectBuilder_EntityBase>();
            int count = 0;

            Wrapper.GameAction(() =>
            {
                foreach (IMyEntity entity in entities)
                {
                    if (entity.InScene)
                    {
                        continue;
                    }

                    if (!(entity is IMyCubeGrid))
                    {
                        continue;
                    }

                    MyObjectBuilder_CubeGrid builder = CubeGrids.SafeGetObjectBuilder((IMyCubeGrid)entity);
                    if (builder == null)
                    {
                        continue;
                    }

                    count++;
                    if (!force)
                    {
                        continue;
                    }

                    IMyCubeGrid grid = (IMyCubeGrid)entity;
                    long ownerId     = 0;
                    string ownerName = "";
                    if (grid.BigOwners.Count > 0)
                    {
                        ownerId   = grid.BigOwners.First();
                        ownerName = PlayerMap.Instance.GetPlayerItemFromPlayerId(ownerId).Name;
                    }

                    grid.PersistentFlags    = (MyPersistentEntityFlags2.InScene | MyPersistentEntityFlags2.CastShadows);
                    grid.InScene            = true;
                    grid.CastShadows        = true;
                    builder.PersistentFlags = (MyPersistentEntityFlags2.InScene | MyPersistentEntityFlags2.CastShadows);
                    MyAPIGateway.Entities.RemapObjectBuilder(builder);
                    //Log.Info("Conceal", string.Format("Force Revealing - Id: {0} -> {4} Display: {1} OwnerId: {2} OwnerName: {3}", entity.EntityId, entity.DisplayName.Replace("\r", "").Replace("\n", ""), ownerId, ownerName, builder.EntityId));
                    Log.Info("Revealing");

                    /*
                     * entity.InScene = true;
                     * entity.CastShadows = true;
                     * entity.Visible = true;
                     */

                    //CubeGridEntity newEntity = new CubeGridEntity(builder);
                    //SectorObjectManager.Instance.AddEntity(newEntity);

                    //BaseEntityNetworkManager.BroadcastRemoveEntity(entity);
                    MyAPIGateway.Entities.CreateFromObjectBuilderAndAdd(builder);
                    addList.Add(builder);
                    //MyAPIGateway.Multiplayer.SendEntitiesCreated(addList);
                    addList.Clear();
                }
            });

            Log.Info(!force ? string.Format("Command would Reveal {0} grids.  Type /admin reveal force to reveal them.", count) : string.Format("Command Revealed {0} grids", count));

            return(true);
        }
コード例 #41
0
    public static T[] FromJson <T>(string json)
    {
        Wrapper <T> wrapper = JsonUtility.FromJson <Wrapper <T> >(json);

        return(wrapper.Items);
    }
コード例 #42
0
ファイル: JsonHelper.cs プロジェクト: Bitouse/Foot_Strat
	public static string ToJson<T>(T[] array, bool prettyPrint)
	{
		Wrapper<T> wrapper = new Wrapper<T>();
		wrapper.Items = array;
		return JsonUtility.ToJson(wrapper, prettyPrint);
	}
コード例 #43
0
        private void CheckPlayerInDockingZone(IMyPlayer player)
        {
            if (player.Controller == null || player.Controller.ControlledEntity == null || player.Controller.ControlledEntity.Entity == null)
            {
                return;
            }

            IMyEntity entity   = player.Controller.ControlledEntity.Entity;
            long      playerId = player.PlayerID;
            IMyEntity parent   = entity.GetTopMostParent();

            // Not a ship?  let's not process
            if (!(parent is IMyCubeGrid))
            {
                if (m_playersInside.Contains(playerId))
                {
                    m_playersInside.Remove(playerId);
                    ulong steamId = PlayerMap.Instance.GetSteamIdFromPlayerId(playerId);
                    Communication.Notification(steamId, MyFontEnum.DarkBlue, 7, "You have exited a ship in a docking zone");
                }

                return;
            }

            // Get All ships with 500m
            BoundingSphereD  sphere         = new BoundingSphereD(parent.GetPosition(), 500);
            List <IMyEntity> nearByEntities = null;

            // Live dangerously (no wrapper for speed!)
            //actually it causes crashes :(
            try
            {
                Wrapper.GameAction(() =>
                {
                    nearByEntities = MyAPIGateway.Entities.GetEntitiesInSphere(ref sphere);
                });
            }
            catch (Exception ex)
            {
                Essentials.Log.Error(ex);
                return;
            }

            if (nearByEntities == null)
            {
                return;
            }

            List <IMyEntity> nearByGrids = nearByEntities.FindAll(x => x is IMyCubeGrid);

            // See if player's ship is inside a docking zone
            foreach (IMyEntity nearByEntity in nearByGrids)
            {
                // Sanity Check
                if (!(nearByEntity is IMyCubeGrid))
                {
                    return;
                }

                IMyCubeGrid cubeGrid = (IMyCubeGrid)nearByEntity;
                // Does this grid contain a docking zone?
                if (m_zoneCache.Contains(cubeGrid))
                {
                    Dictionary <String, List <IMyCubeBlock> > zoneList = DockingZone.GetZonesInGrid(cubeGrid);
                    if (zoneList == null)
                    {
                        continue;
                    }

                    // Get zones
                    foreach (KeyValuePair <string, List <IMyCubeBlock> > p in zoneList)
                    {
                        // Check if we're inside
                        if (DockingZone.IsGridInside((IMyCubeGrid)parent, p.Value))
                        {
                            if (!m_playersInside.Contains(playerId))
                            {
                                m_playersInside.Add(playerId);
                                ulong steamId = PlayerMap.Instance.GetSteamIdFromPlayerId(playerId);
                                Communication.Notification(steamId, MyFontEnum.Green, 7, $"You are inside a valid docking zone: {p.Key}");
                            }

                            return;
                        }
                    }
                }
            }

            // We've left
            if (m_playersInside.Contains(playerId))
            {
                m_playersInside.Remove(playerId);
                ulong steamId = PlayerMap.Instance.GetSteamIdFromPlayerId(playerId);
                Communication.Notification(steamId, MyFontEnum.Red, 7, "You have left a docking zone");
            }
        }
コード例 #44
0
 public ElementDetailController(Wrapper wrapper)
 {
     _wrapper = wrapper;
 }
コード例 #45
0
 public Task <Wrapper> DoComplex(Wrapper wrapper)
 {
     return(Worker.DoComplex(wrapper));
 }
コード例 #46
0
        // admin nobeacon scan
        public override bool HandleCommand(ulong userId, string[] words)
        {
            if (words.Count() != 2)
            {
                Communication.SendPrivateInformation(userId, GetHelp());
                return(true);
            }

            string blockType  = words[0].ToLower();
            int    blockCount = 0;

            if (!int.TryParse(words[1], out blockCount))
            {
                Communication.SendPrivateInformation(userId, string.Format("Invalid block count: {0}", words[1]));
                return(true);
            }

            blockCount = Math.Max(blockCount, 1);

            Communication.SendPrivateInformation(userId, string.Format("Looking for grids that contain more than {0} of type {1}", blockCount, blockType));

            HashSet <IMyEntity> entities = new HashSet <IMyEntity>();

            Wrapper.GameAction(() =>
            {
                MyAPIGateway.Entities.GetEntities(entities, x => x is IMyCubeGrid);
            });

            HashSet <IMyEntity> entitiesToConfirm   = new HashSet <IMyEntity>();
            HashSet <IMyEntity> entitiesUnconnected = new HashSet <IMyEntity>();
            HashSet <IMyEntity> entitiesFound       = new HashSet <IMyEntity>();

            foreach (IMyEntity entity in entities)
            {
                if (!(entity is IMyCubeGrid))
                {
                    continue;
                }

                IMyCubeGrid grid = (IMyCubeGrid)entity;
                MyObjectBuilder_CubeGrid gridBuilder = CubeGrids.SafeGetObjectBuilder(grid);
                if (gridBuilder == null)
                {
                    continue;
                }

                if (PluginSettings.Instance.LoginEntityWhitelist.Contains(entity.EntityId.ToString()))
                {
                    continue;
                }

                entitiesToConfirm.Add(entity);
            }

            CubeGrids.GetGridsUnconnected(entitiesUnconnected, entitiesToConfirm);
            foreach (IMyEntity entity in entitiesUnconnected)
            {
                IMyCubeGrid grid = (IMyCubeGrid)entity;
                MyObjectBuilder_CubeGrid gridBuilder = CubeGrids.SafeGetObjectBuilder((IMyCubeGrid)entity);
                if (gridBuilder == null)
                {
                    continue;
                }

                int count = 0;
                foreach (MyObjectBuilder_CubeBlock block in gridBuilder.CubeBlocks)
                {
                    if (block.GetId().SubtypeName.ToLower().Contains(blockType))
                    {
                        count++;
                    }
                }

                if (count >= blockCount)
                {
                    Communication.SendPrivateInformation(userId, string.Format("Found grid '{0}' ({1}) owned by '{5}' which has more than {3} blocks of type {4}.  BlockCount={2}", entity.DisplayName, entity.EntityId, ((MyObjectBuilder_CubeGrid)entity.GetObjectBuilder()).CubeBlocks.Count, blockCount, blockType, grid.BigOwners.Count > 0 ? PlayerMap.Instance.GetPlayerItemFromPlayerId(grid.BigOwners.First()).Name : "No one"));
                    entitiesFound.Add(entity);
                    continue;
                }
            }

            /*
             * foreach(IMyEntity entity in entitiesFound)
             * {
             *      IMyCubeGrid grid = (IMyCubeGrid)entity;
             * }
             */

            Communication.SendPrivateInformation(userId, string.Format("Found {0} grids considered to be overlimit", entitiesFound.Count));
            return(true);
        }
コード例 #47
0
 public MainPresenter(string username, string password)
 {
     wrapper = new Wrapper(username, password);
 }
コード例 #48
0
 public void Configure(BehaviorGraph graph)
 {
     graph.Handlers.Each(x => x.InsertFirst(Wrapper.For <FooWrapper>()));
 }
コード例 #49
0
 public Task SubscribeAsync(string channelName, Action <IPubSubMessage> action, CommandFlags flag = CommandFlags.None) => Wrapper.Subscriber.Value.SubscribeAsync(GetRealChannelName(channelName), (c, v) => action(Wrapper.Unwrap <PubSubMessageModel>(v)));
コード例 #50
0
        public override T Get(object id)
        {
            var entity = Wrapper.Get(id);

            return(CreateInterfaceProxyWithTarget(entity));
        }
コード例 #51
0
    public static List <T> FromJson <T>(string json)
    {
        Wrapper wrapper = JsonUtility.FromJson <Wrapper>(json);

        return(new List <T>(wrapper.Items.Select(i => JsonUtility.FromJson <T>(i)).ToList()));
    }
コード例 #52
0
 protected internal override void Add(Wrapper item)
 {
     cache.GetOrCreate(item.Item.TxInputOutput.Address).Add(item);
 }
コード例 #53
0
 public int CompareTo(Wrapper <T> other)
 {
     return(this.Key.CompareTo(other.Key));
 }
コード例 #54
0
    private static T[] ArrayFromJson <T>(string json) ////Helper-functie om de wrapped array te deserialisen
    {
        Wrapper <T> wrapper = JsonUtility.FromJson <Wrapper <T> >(json);

        return(wrapper.Items);
    }
コード例 #55
0
        public override void Handle()
        {
            if (!PluginSettings.Instance.NewUserTransportEnabled)
            {
                return;
            }

            if (MyAPIGateway.Players == null)
            {
                return;
            }

            if (PluginSettings.Instance.NewUserTransportStopRunawaySpawnShips)
            {
                if (DateTime.Now - LastUpdate > TimeSpan.FromSeconds(5))
                {
                    LastUpdate = DateTime.Now;
                    HashSet <IMyEntity> entities = new HashSet <IMyEntity>();
                    try
                    {
                        MyAPIGateway.Entities.GetEntities(entities);
                    }
                    catch
                    {
                        Essentials.Log.Info(string.Format("StopRunaway(): Entities busy, skipping"));
                        return;
                    }

                    foreach (IMyEntity entity in entities)
                    {
                        if (!(entity is IMyCubeGrid))
                        {
                            continue;
                        }

                        bool found = PluginSettings.Instance.NewUserTransportSpawnShipNames.Any(name => entity.DisplayName.Contains(name));

                        if (!found)
                        {
                            continue;
                        }

                        IMyCubeGrid grid = (IMyCubeGrid)entity;
                        if (grid.Physics == null)
                        {
                            continue;
                        }
                        bool foundControlled = PlayerManager.Instance.ConnectedPlayers.Select(steamId => PlayerMap.Instance.GetFastPlayerIdFromSteamId(steamId)).Select(Player.FindControlledEntity).Any(testEntity => testEntity == entity);

                        if (foundControlled)
                        {
                            continue;
                        }

                        Wrapper.GameAction(() =>
                        {
                            try
                            {
                                double linear  = Math.Round(grid.Physics.LinearVelocity.LengthSquared(), 1);
                                double angular = Math.Round(grid.Physics.AngularVelocity.LengthSquared(), 1);

                                if (linear > 0 || angular > 0)
                                {
                                    grid.Physics.LinearVelocity  = Vector3.Zero;
                                    grid.Physics.AngularVelocity = Vector3.Zero;
                                    Essentials.Log.Info("Stopping runaway spawnship: {0}", grid.EntityId);
                                }
                            }
                            catch (Exception ex)
                            {
                                Essentials.Log.Error(ex, "Error stopping spawnship: {0}", ex);
                            }
                        });
                    }
                }
            }

            base.Handle();
        }
コード例 #56
0
 protected internal override void Add(Wrapper item)
 {
     cache.GetOrCreate(item.Item.TransactionHash).Add(item);
 }
コード例 #57
0
    //Usage:
    //YouObject[] objects = JsonHelper.getJsonArray<YouObject> (jsonString);
    public static T[] getJsonArray <T>(string json)
    {
        Wrapper <T> wrapper = JsonUtility.FromJson <Wrapper <T> > (json);

        return(wrapper.array);
    }
コード例 #58
0
ファイル: JsonHelper.cs プロジェクト: Bitouse/Foot_Strat
	public static string ToJson<T>(T[] array)
	{
		Wrapper<T> wrapper = new Wrapper<T>();
		wrapper.Items = array;
		return JsonUtility.ToJson(wrapper);
	}
コード例 #59
0
        private static int TutorialAddModule1()
        {
            try
            {
                OpenPose.Log("Starting OpenPose demo...", Priority.High);
                var timeBegin = new Stopwatch();
                timeBegin.Start();

                // logging_level
                OpenPose.Check(0 <= Flags.LoggingLevel && Flags.LoggingLevel <= 255, "Wrong logging_level value.");
                ConfigureLog.PriorityThreshold = (Priority)Flags.LoggingLevel;
                Profiler.SetDefaultX((ulong)Flags.ProfileSpeed);

                // Applying user defined configuration - GFlags to program variables
                // cameraSize
                var cameraSize = OpenPose.FlagsToPoint(Flags.CameraResolution, "-1x-1");
                // outputSize
                var outputSize = OpenPose.FlagsToPoint(Flags.OutputResolution, "-1x-1");
                // netInputSize
                var netInputSize = OpenPose.FlagsToPoint(Flags.NetResolution, "-1x368");
                // faceNetInputSize
                var faceNetInputSize = OpenPose.FlagsToPoint(Flags.FaceNetResolution, "368x368 (multiples of 16)");
                // handNetInputSize
                var handNetInputSize = OpenPose.FlagsToPoint(Flags.HandNetResolution, "368x368 (multiples of 16)");
                // producerType
                var tie            = OpenPose.FlagsToProducer(Flags.ImageDir, Flags.Video, Flags.IpCamera, Flags.Camera, Flags.FlirCamera, Flags.FlirCameraIndex);
                var producerType   = tie.Item1;
                var producerString = tie.Item2;
                // poseModel
                var poseModel = OpenPose.FlagsToPoseModel(Flags.ModelPose);
                // JSON saving
                if (!string.IsNullOrEmpty(Flags.WriteKeyPoint))
                {
                    OpenPose.Log("Flag `write_keypoint` is deprecated and will eventually be removed. Please, use `write_json` instead.");
                }
                // keypointScale
                var keyPointScale = OpenPose.FlagsToScaleMode(Flags.KeyPointScale);
                // heatmaps to add
                var heatMapTypes = OpenPose.FlagsToHeatMaps(Flags.HeatmapsAddParts, Flags.HeatmapsAddBackground, Flags.HeatmapsAddPAFs);
                var heatMapScale = OpenPose.FlagsToHeatMapScaleMode(Flags.HeatmapsScale);
                // >1 camera view?
                var multipleView = (Flags.Enable3D || Flags.Views3D > 1 || Flags.FlirCamera);
                // Enabling Google Logging
                const bool enableGoogleLogging = true;

                // Configuring OpenPose
                OpenPose.Log("Configuring OpenPose...", Priority.High);
                using (var opWrapper = new Wrapper <CustomDatum>())
                {
                    // Pose configuration (use WrapperStructPose{} for default and recommended configuration)
                    using (var pose = new WrapperStructPose(!Flags.BodyDisabled,
                                                            netInputSize,
                                                            outputSize,
                                                            keyPointScale,
                                                            Flags.NumGpu,
                                                            Flags.NumGpuStart,
                                                            Flags.ScaleNumber,
                                                            (float)Flags.ScaleGap,
                                                            OpenPose.FlagsToRenderMode(Flags.RenderPose, multipleView),
                                                            poseModel,
                                                            !Flags.DisableBlending,
                                                            (float)Flags.AlphaPose,
                                                            (float)Flags.AlphaHeatmap,
                                                            Flags.PartToShow,
                                                            Flags.ModelFolder,
                                                            heatMapTypes,
                                                            heatMapScale,
                                                            Flags.PartCandidates,
                                                            (float)Flags.RenderThreshold,
                                                            Flags.NumberPeopleMax,
                                                            Flags.MaximizePositives,
                                                            Flags.FpsMax,
                                                            enableGoogleLogging))
                        // Face configuration (use op::WrapperStructFace{} to disable it)
                        using (var face = new WrapperStructFace(Flags.Face,
                                                                faceNetInputSize,
                                                                OpenPose.FlagsToRenderMode(Flags.FaceRender, multipleView, Flags.RenderPose),
                                                                (float)Flags.FaceAlphaPose,
                                                                (float)Flags.FaceAlphaHeatmap,
                                                                (float)Flags.FaceRenderThreshold))
                            // Hand configuration (use op::WrapperStructHand{} to disable it)
                            using (var hand = new WrapperStructHand(Flags.Hand,
                                                                    handNetInputSize,
                                                                    Flags.HandScaleNumber,
                                                                    (float)Flags.HandScaleRange, Flags.HandTracking,
                                                                    OpenPose.FlagsToRenderMode(Flags.HandRender, multipleView, Flags.RenderPose),
                                                                    (float)Flags.HandAlphaPose,
                                                                    (float)Flags.HandAlphaHeatmap,
                                                                    (float)Flags.HandRenderThreshold))
                                // Extra functionality configuration (use op::WrapperStructExtra{} to disable it)
                                using (var extra = new WrapperStructExtra(Flags.Enable3D,
                                                                          Flags.MinViews3D,
                                                                          Flags.Identification,
                                                                          Flags.Tracking,
                                                                          Flags.IkThreads))
                                    // Producer (use default to disable any input)
                                    using (var input = new WrapperStructInput(producerType,
                                                                              producerString,
                                                                              Flags.FrameFirst,
                                                                              Flags.FrameStep,
                                                                              Flags.FrameLast,
                                                                              Flags.ProcessRealTime,
                                                                              Flags.FrameFlip,
                                                                              Flags.FrameRotate,
                                                                              Flags.FramesRepeat,
                                                                              cameraSize,
                                                                              Flags.CameraParameterPath,
                                                                              Flags.FrameUndistort,
                                                                              Flags.Views3D))
                                        // Output (comment or use default argument to disable any output)
                                        using (var output = new WrapperStructOutput(Flags.CliVerbose,
                                                                                    Flags.WriteKeyPoint,
                                                                                    OpenPose.StringToDataFormat(Flags.WriteKeyPointFormat),
                                                                                    Flags.WriteJson,
                                                                                    Flags.WriteCocoJson,
                                                                                    Flags.WriteCocoFootJson,
                                                                                    Flags.WriteCocoJsonVariant,
                                                                                    Flags.WriteImages,
                                                                                    Flags.WriteImagesFormat,
                                                                                    Flags.WriteVideo,
                                                                                    Flags.WriteVideoFps,
                                                                                    Flags.WriteHeatmaps,
                                                                                    Flags.WriteHeatmapsFormat,
                                                                                    Flags.WriteVideoAdam,
                                                                                    Flags.WriteBvh,
                                                                                    Flags.UdpHost,
                                                                                    Flags.UdpPort))
                                            // GUI (comment or use default argument to disable any visual output)
                                            using (var gui = new WrapperStructGui(OpenPose.FlagsToDisplayMode(Flags.Display, Flags.Enable3D),
                                                                                  !Flags.NoGuiVerbose,
                                                                                  Flags.FullScreen))
                                            {
                                                opWrapper.Configure(pose);
                                                opWrapper.Configure(face);
                                                opWrapper.Configure(hand);
                                                opWrapper.Configure(extra);
                                                opWrapper.Configure(input);
                                                opWrapper.Configure(output);
                                                opWrapper.Configure(gui);

                                                // Custom post-processing
                                                var userPostProcessing = new UserPostProcessing(/* Your class arguments here */);
                                                using (var wUserPostProcessing = new StdSharedPtr <UserWorker <CustomDatum> >(new WUserPostProcessing(userPostProcessing)))
                                                {
                                                    // Add custom processing
                                                    const bool workerProcessingOnNewThread = false;
                                                    opWrapper.SetWorker(WorkerType.PostProcessing, wUserPostProcessing, workerProcessingOnNewThread);

                                                    // Set to single-thread (for sequential processing and/or debugging and/or reducing latency)
                                                    if (Flags.DisableMultiThread)
                                                    {
                                                        opWrapper.DisableMultiThreading();
                                                    }

                                                    OpenPose.Log("Starting thread(s)...", Priority.High);
                                                    // Start, run & stop threads - it blocks this thread until all others have finished
                                                    opWrapper.Exec();

                                                    // Measuring total time
                                                    timeBegin.Stop();
                                                    var totalTimeSec = timeBegin.ElapsedMilliseconds * 1000;
                                                    var message      = $"OpenPose demo successfully finished. Total time: {totalTimeSec} seconds.";
                                                    OpenPose.Log(message, Priority.High);
                                                }
                                            }
                }

                // Return successful message
                return(0);
            }
            catch (Exception)
            {
                return(-1);
            }
        }
コード例 #60
0
 private void InitializeCommands()
 {
     ApplyTextTable = new Command(p1 => Apply(), p2 => Wrapper.True());
 }